Q:

masterpage deployment package

I have got masterpage and css related to it given by our designer.
I want to create master page package programmatically. I have created feature for it and added event reciever to it. But i dont know exactly where to put masterpage and css files in project. Is there good way to keep this files? Should i create folder for mastepage and css files seperately. I hope this is correct way to apply masterpage .
private static void ApplyMasterPage(SPSite site, string url, string systemUrl)
    {
        try
        {
            using (SPWeb rootWeb = site.RootWeb)
            {
                Uri masterUri = new Uri(string.Format(url, rootWeb.Url));
                Uri systemUri = new Uri(string.Format(systemUrl, rootWeb.Url));
                rootWeb.CustomMasterUrl = masterUri.AbsolutePath;
                rootWeb.MasterUrl = systemUri.AbsolutePath;
                rootWeb.Update();

                foreach (SPWeb web in site.AllWebs)
                {

                    SPSecurity.RunWithElevatedPrivileges(delegate ()
                    {
                        if (!web.IsRootWeb)
                        {
                            web.CustomMasterUrl = masterUri.AbsolutePath;
                            web.MasterUrl = systemUri.AbsolutePath;
                            web.AllowUnsafeUpdates = true;
                            web.Update();
                        }
                    });
                }
            }
        }
        catch (Exception)
        {
            throw;
        }
    }

In masterpage css is referred as below
 <link id="Link3" rel="stylesheet" runat="server" type="text/css" href="<% $SPUrl:~SiteCollection/Style%20Library/mycss.css%>" media="screen,projection"/>

I wish to know below things

Where to put masterpage and css files in solution?
How to refer css files in code.

A:

Typically I create a module to host master pages, deployed to _catalogs/masterpage, a mapped layouts for css and a mapped images for images. 
If you want to store at the site level, you can use modules for that too.
e.g. mp module
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="MasterPages" Path="MasterPages" Url="_catalogs/masterpage" List="116">
    <File Path="Custom.master" Url="Custom.master" ReplaceContent="TRUE" Type="GhostableInLibrary" >
      <Property Name="UIVersion" Value="15"></Property>
      <Property Name="MasterPageDescription" Value="My Custom Master Page" />
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" />
    </File>    
  </Module>

e.g. style lib module
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Styles" Url="Style Library">    
    <File Path="Styles\mycss.css" Url="mycss.css" Type="GhostableInLibrary"/>

  </Module>
</Elements>

example file structure:
>solution
 > project
   > masterpages (module)
     > custom.master
   > styles (module)
     > mycss.css
     > images
       > image1.png

More here:
Using Modules to Include Files in the Solution

