コード例 #1
0
        public string CreateFirst(dynamic requestData)
        {
            ReturnJson r = new ReturnJson();
            string     q = JsonConvert.SerializeObject(requestData.List);
            List <CpkFirstCategory> model = JsonConvert.DeserializeObject <List <CpkFirstCategory> >(q);

            foreach (var item in model)
            {
                var sql   = string.Format("Select 1 from CpkFirstCategory Where FirstName = '{0}'", item.FirstName);
                var count = dataContext.GetCount(CommandType.Text, sql);
                if (count == 0)
                {
                    db.CpkFirstCategory.Add(item);
                    db.SaveChanges();
                }
                else
                {
                    r.message += item.FirstName + "已存在;";
                }
                if (string.IsNullOrEmpty(r.message))
                {
                    r.status  = "succ";
                    r.message = "添加成功";
                }
            }
            return(JsonConvert.SerializeObject(r));
        }
コード例 #2
0
        public string AddTutorComment(dynamic requestData)
        {
            try
            {
                string       addTutor = JsonConvert.SerializeObject(requestData);
                TutorComment model    = JsonConvert.DeserializeObject <TutorComment>(addTutor);
                model.CreateTime = DateTime.Now;
                db.TutorComment.Add(model);
                db.SaveChanges();


                var q = (from v in db.TutorComment
                         where v.TutorId == model.TutorId
                         orderby v.CreateTime descending
                         select new
                {
                    TutorCommentId = v.TutorCommentId,
                    MemberName = v.MemberName,
                    HeadPicUrl = v.HeadPicUrl,
                    Commemt = v.Comment,
                    CreateTime = v.CreateTime
                });
                int count = q.Count();
                var lastq = q.OrderByDescending(v => v.CreateTime).Skip(0).Take(3);
                var iso   = new IsoDateTimeConverter();
                iso.DateTimeFormat = "yyyy-MM-dd hh:mm";

                return("{ \"Count\":\"" + count + "\",\"data\":" + JsonConvert.SerializeObject(lastq, iso) + "}");
            }
            catch (Exception e)
            {
                return("No");
            }
        }
コード例 #3
0
 public string AddChefActivity(dynamic requestData)
 {
     try
     {
         string       query = JsonConvert.SerializeObject(requestData);
         ChefActivity model = JsonConvert.DeserializeObject <ChefActivity>(query);
         #region 每次新增确保只有一个是进行状态
         if (model.IsEnable == 1)
         {
             var qchefActivity = (from v in db.ChefActivity
                                  where v.IsEnable == 1
                                  select v).FirstOrDefault();
             if (qchefActivity != null)
             {
                 if (qchefActivity.IsEnable == 1)
                 {
                     qchefActivity.IsEnable = 0;
                     db.SaveChanges();
                 }
             }
         }
         #endregion
         model.CreateTime = DateTime.Now;
         model.UpdateTime = DateTime.Now;
         model.IsDel      = 1;
         db.ChefActivity.Add(model);
         db.SaveChanges();
         return("OK");
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
コード例 #4
0
        public string AddRegistCode(string salemanId)
        {
            try
            {
                int Id = Convert.ToInt32(salemanId);
                if (Id <= 0)
                {
                    return("Request Parameter Error");
                }

                for (int i = 0; i < 10; i++)
                {
                    RegistCode code = new RegistCode();
                    code.SalemanId       = Id;
                    code.MemberId        = 0;
                    code.RegistCodeState = 1;
                    code.GenerDate       = DateTime.Now;
                    //code.UseDate = DateTime.MinValue;

                    db.RegistCode.Add(code);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                return("程序出错,信息为:" + ex.InnerException);
            }

            return("Succss");
        }
コード例 #5
0
        public string AddECBrowseDetails(dynamic requestData)
        {
            try
            {
                string BrowseDetails = JsonConvert.SerializeObject(requestData);
                var    q             = JsonConvert.DeserializeObject <ECBrowseDetails>(BrowseDetails);
                lock (Lock)
                {
                    //详情页是否包含
                    var IsPV = (from v in db.ECBrowseDetails
                                where v.ECURL == q.ECURL
                                select v).FirstOrDefault();

                    //如果详情里面没有这
                    if (IsPV == null)
                    {
                        ECBrowse newqECBrowse = new ECBrowse();
                        newqECBrowse.ECURL = q.ECURL;
                        newqECBrowse.PV    = 1;
                        newqECBrowse.UV    = 1;
                        //db.ECBrowse.Add(newqECBrowse);
                        var sql = string.Format("INSERT INTO [dbo].[ECBrowse]([ECURL],[PV],[UV],[Transpond]) VALUES('{0}',{1},{2},0)", newqECBrowse.ECURL, newqECBrowse.PV, newqECBrowse.UV);
                        dataContext.ExecuteNonQuery(CommandType.Text, sql);
                    }
                    else
                    {
                        //查找EC总的是否有
                        var qECBrowse = (from v in db.ECBrowse
                                         where v.ECURL == q.ECURL
                                         select v).FirstOrDefault();

                        if (qECBrowse != null)
                        {
                            qECBrowse.PV = qECBrowse.PV + 1;

                            var IsUV = (from v in db.ECBrowseDetails
                                        where v.ECURL == q.ECURL && v.OpenId == q.OpenId
                                        select v).FirstOrDefault();
                            Thread.Sleep(500);
                            if (IsUV == null)
                            {
                                qECBrowse.UV = qECBrowse.UV + 1;
                            }

                            var sqlPVUV = string.Format("UPDATE  [dbo].[ECBrowse]  SET  [PV] = {0},[UV] = {1}  WHERE Id={2}", qECBrowse.PV, qECBrowse.UV, qECBrowse.Id);
                            dataContext.ExecuteNonQuery(CommandType.Text, sqlPVUV);
                        }
                    }
                }
                db.ECBrowseDetails.Add(q);
                db.SaveChanges();

                return("OK");
            }
            catch (Exception)
            {
                return("No");
            }
        }
コード例 #6
0
        public int SaveMemberResume(dynamic requestData)
        {
            string       query = JsonConvert.SerializeObject(requestData);
            MemberResume model = JsonConvert.DeserializeObject <MemberResume>(query);

            db.MemberResume.Add(model);
            db.SaveChanges();

            return(model.ResumeId);
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "BidId,Name,CreditHead,bidDate")] Bid bid)
        {
            if (ModelState.IsValid)
            {
                db.Bids.Add(bid);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bid));
        }
コード例 #8
0
        public ActionResult Create([Bind(Include = "CreditId,Head,Period,Sum,Procent")] Credit credit)
        {
            if (ModelState.IsValid)
            {
                db.Credits.Add(credit);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(credit));
        }
コード例 #9
0
        public string AddSigninCredit(dynamic requestData)
        {
            try
            {
                int MemberId = JsonConvert.DeserializeObject <int>(JsonConvert.SerializeObject(requestData.MemberId));

                var datatime = DateTime.Today;

                var q = (from v in db.SigninCreditLog
                         where v.MemberId == MemberId && v.SigninData == datatime
                         select v
                         ).FirstOrDefault();
                if (q == null)
                {
                    SigninCreditLog s = new SigninCreditLog();
                    s.SigninData = datatime;
                    s.MemberId   = MemberId;
                    db.SigninCreditLog.Add(s);

                    SigninCredit sC    = new SigninCredit();
                    var          sccun = (from v in db.SigninCredit
                                          where v.MemberId == MemberId
                                          select v
                                          ).FirstOrDefault();
                    if (sccun == null)
                    {
                        sC.MemberId     = MemberId;
                        sC.CreditsCount = 1;
                        sC.CreateTime   = DateTime.Now;
                        sC.UpdateTime   = DateTime.Now;
                        db.SigninCredit.Add(sC);
                    }
                    else
                    {
                        sccun.CreditsCount = sccun.CreditsCount + 1;
                        sccun.UpdateTime   = DateTime.Now;
                        db.Entry <SigninCredit>(sccun).State = EntityState.Modified;
                    }
                    db.SaveChanges();
                    return("OK");
                }
                else
                {
                    return("2");
                }
            }
            catch (Exception)
            {
                return("No");
            }
        }
コード例 #10
0
 public string AddPrizeHTD(dynamic requestData)
 {
     try
     {
         var homeOpenId = JsonConvert.DeserializeObject <PrizeOpenIdHomeTasteDraw>(JsonConvert.SerializeObject(requestData));
         db.PrizeOpenIdHomeTasteDraw.Add(homeOpenId);
         db.SaveChanges();
         return("OK");
     }
     catch (Exception)
     {
         return("No");
     }
 }
コード例 #11
0
        public string AddFlavourRec(dynamic requestData)
        {
            try
            {
                string updateSingle = JsonConvert.SerializeObject(requestData);
                var    q            = JsonConvert.DeserializeObject <FlavourRec>(updateSingle);

                var qFlavourRec = (from v in db.FlavourRec
                                   where v.FlavourName == q.FlavourName && v.ChefActivityId == q.ChefActivityId && v.FlavourType == q.FlavourType
                                   select v
                                   ).FirstOrDefault();
                if (qFlavourRec != null)
                {
                    return("名称重复");
                }
                q.CreateTime = DateTime.Now;
                q.UpdateTime = DateTime.Now;
                db.FlavourRec.Add(q);
                db.SaveChanges();
                return("OK");
            }
            catch (Exception)
            {
                return("No");
            }
        }
コード例 #12
0
        public string SaveAddress(dynamic requestData)
        {
            try
            {
                string  query = JsonConvert.SerializeObject(requestData);
                Address model = JsonConvert.DeserializeObject <Address>(query);

                db.Address.Add(model);
                db.SaveChanges();
                return(model.AddressId.ToString());
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
コード例 #13
0
        public string AddChef(Chef requestData)
        {
            try
            {
                //string query = JsonConvert.SerializeObject(requestData);
                //Chef model = JsonConvert.DeserializeObject<Chef>(query);
                Chef model = requestData;
                if (model.Birthday == Convert.ToDateTime("0001/1/1 0:00:00"))
                {
                    model.Birthday = Convert.ToDateTime("1900-1-1");
                }
                var q = (from v in db.Chef
                         where v.MemberId == model.MemberId && v.ChefActivityId == model.ChefActivityId
                         select v
                         ).FirstOrDefault();

                if (q == null)
                {
                    db.Chef.Add(model);
                    db.SaveChanges();
                    return(model.ChefId.ToString());
                }
                else
                {
                    q.MemberId       = model.MemberId;
                    q.ChefActivityId = model.ChefActivityId;
                    q.MatchRegionId  = model.MatchRegionId;
                    q.ApplyType      = model.ApplyType;
                    q.ReferrerName   = model.ReferrerName;
                    q.Birthday       = model.Birthday;
                    q.ChefPicUrl     = model.ChefPicUrl;
                    //q.ChefHotelName = model.ChefHotelName;
                    q.ChefHotelPicUrl        = model.ChefHotelPicUrl;
                    db.Entry <Chef>(q).State = EntityState.Modified;
                    db.SaveChanges();

                    string update = "update DishChef set IsApply=0 where ChefId=" + q.ChefId;
                    dataContext.ExecuteNonQuery(CommandType.Text, update);

                    return(q.ChefId.ToString());
                }
            }
            catch (Exception)
            {
                return("No");
            }
        }
コード例 #14
0
        public string SaveDrawPrize(dynamic requestData)
        {
            try
            {
                string    query = JsonConvert.SerializeObject(requestData);
                DrawPrize model = JsonConvert.DeserializeObject <DrawPrize>(query);
                model.CreateDate = DateTime.Now;
                db.DrawPrize.Add(model);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return("Exc Success");
        }
コード例 #15
0
 public string CreateBid(Bid newBid)
 {
     newBid.bidDate = DateTime.Now;
     // Добавляем новую заявку в БД
     db.Bids.Add(newBid);
     // Сохраняем в БД все изменения
     db.SaveChanges();
     return("Спасибо, <b>" + newBid.Name + "</b>, за выбор нашего банка. Ваша заявка будет рассмотрена в течении 10 дней.");
 }
コード例 #16
0
        public string AddRegion(string requestData)
        {
            Region model = JsonConvert.DeserializeObject <Region>(requestData);

            model.CreateDate = DateTime.Now;
            db.Region.Add(model);
            db.SaveChanges();
            return(model.RegionName);
        }
コード例 #17
0
        public string AddMemberProfile(string requestData)
        {
            string        query = JsonConvert.SerializeObject(requestData);
            MemberProfile model = JsonConvert.DeserializeObject <MemberProfile>(query);

            db.MemberProfile.Add(model);
            db.SaveChanges();
            return(model.MemberId.ToString());
        }
コード例 #18
0
        public string AddOpenIdAssociate(string requestData)
        {
            OpenIdAssociated model = JsonConvert.DeserializeObject <OpenIdAssociated>(requestData);

            db.OpenIdAssociated.Add(model);
            db.SaveChanges();

            return(model.UserId.ToString());
        }
コード例 #19
0
ファイル: MemberAuthController.cs プロジェクト: Locdee/ecs
        public string RealAuthAdd(dynamic requestData)
        {
            try
            {
                string         query = JsonConvert.SerializeObject(requestData);
                MemberRealAuth model = JsonConvert.DeserializeObject <MemberRealAuth>(query);
                model.AuthTime = DateTime.Now;

                db.MemberRealAuth.Add(model);
                db.SaveChanges();
                //return JsonConvert.SerializeObject(model);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return("Exc Success");
        }
コード例 #20
0
        public string AddRegistSaleMan(dynamic requestData)
        {
            OpenIdAssociated openbase = new OpenIdAssociated();

            RegistSaleMan saleman = new RegistSaleMan();

            saleman.ProvinceId   = requestData.ProvinceId;
            saleman.ProvinceName = requestData.ProvinceName;
            saleman.CityId       = requestData.CityId;
            saleman.CityName     = requestData.CityName;
            saleman.AreaId       = requestData.AreaId;
            saleman.AreaName     = requestData.AreaName;
            saleman.RegionId     = requestData.RegionId;
            saleman.RegionName   = requestData.RegionName;
            saleman.WorkNum      = requestData.WorkNum;
            saleman.Name         = requestData.Name;
            saleman.Telephone    = requestData.Telephone;
            saleman.CardId       = requestData.CardId;
            saleman.RegistDate   = DateTime.Now;
            saleman.RegistState  = 0;
            saleman.Remark       = "";
            saleman.ImportDate   = null;
            saleman.IsEnable     = 0;

            db.RegistSaleMan.Add(saleman);
            db.SaveChanges();

            #region 获取用户OpenId
            if (requestData.OpenId != null)
            {
                openbase.OpenId     = requestData.OpenId;
                openbase.UserId     = saleman.SalemanId;
                openbase.UserType   = 1;
                openbase.Nickname   = requestData.Nickname;
                openbase.HeadImgUrl = requestData.HeadImgUrl;
                openbase.CreateDate = DateTime.Now;

                db.OpenIdAssociated.Add(openbase);
                db.SaveChanges();
            }
            #endregion

            return(saleman.SalemanId.ToString());
        }
コード例 #21
0
        public string AddBanner(dynamic requestData)
        {
            try
            {
                string addBanner = JsonConvert.SerializeObject(requestData);
                Banner model     = JsonConvert.DeserializeObject <Banner>(addBanner);

                model.UpdateTime   = DateTime.Now;
                model.CreateTime   = DateTime.Now;
                model.UpdatePerson = model.CreatePerson;
                db.Banner.Add(model);

                db.SaveChanges();
                return("OK");
            }
            catch (Exception)
            {
                return("No");
            }
        }
コード例 #22
0
        public void AddToDb()
        {
            var root = HttpContext.Current.Server.MapPath(
                WebConfigurationManager.AppSettings["CreditsRootDirectory"]);

            using (var db = new CreditContext())
            {
                db.Credits.Add(this);
                db.SaveChanges();
            }
        }
コード例 #23
0
        public IActionResult CreditGet(CreditBindingModel creditG)
        {
            // проверяем на валидность моделию,
            if (ModelState.IsValid)
            {
                int summaCredita = creditG.SummaCredit;
                int timeCredit   = creditG.TermCredit;
                int stavkaCrediy = creditG.LendingTate;

                //расчет сум, процентов.
                FullresultCredits = TestRaschet(summaCredita, stavkaCrediy, timeCredit); // Тестовый расчет и запись в бд

                creditBindingModelTemp = creditG;

                listDataCredit = new List <string>()
                {
                    $"Ваша заявка расмотренна!{Environment.NewLine}Сумма кредита:{summaCredita}{Environment.NewLine}Нужный срок кредитования:{timeCredit}{Environment.NewLine}Утвержденная ставка{stavkaCrediy}"
                };

                //Добавляев в БД для статистики
                db.AddRange(
                    new CreditBindingModel
                {
                    SummaCredit = summaCredita,
                    TermCredit  = timeCredit,
                    LendingTate = stavkaCrediy
                }

                    );
                db.SaveChanges(); // сохр. в бд

                return(Redirect("~/Home/CalculateCredit"));
            }

            else
            {
                return(View("creditG")); // возвращаем клиенту на исправление
            }
        }
コード例 #24
0
        public ActionResult Reject(int creditId)
        {
            using (var context = new CreditContext())
            {
                Credit credit = context.Credits.Where(
                    c => c.CreditId == creditId).First();

                credit.Status = Status.Rejected;

                context.SaveChanges();
            }

            return(View());
        }
コード例 #25
0
        public string AddMatchRegion(dynamic requestData)
        {
            try
            {
                string             addMatchRegion = JsonConvert.SerializeObject(requestData);
                List <MatchRegion> model          = JsonConvert.DeserializeObject <List <MatchRegion> >(addMatchRegion);

                ////var allDel = string.Format(@"DELETE MatchRegion where ChefActivityId={0}", model[0].ChefActivityId);
                //dataContext.ExecuteNonQuery(CommandType.Text, allDel);
                foreach (MatchRegion m in model)
                {
                    var q = (from v in db.MatchRegion
                             where v.MatchRegionId == m.MatchRegionId
                             select v).FirstOrDefault();
                    if (q != null)
                    {
                        m.CityName = m.AreaName;
                        // m.CreateTime = DateTime.Now;
                        m.UpdateTime   = DateTime.Now;
                        q.AreaName     = m.AreaName;
                        q.BeginTime    = m.BeginTime;
                        q.CityName     = m.AreaName;
                        q.EndTime      = m.EndTime;
                        q.ProvinceName = m.ProvinceName;
                        q.UpdatePerson = m.UpdatePerson;
                        q.UpdateTime   = DateTime.Now;

                        m.MatchRegionId = 0;
                        db.Entry <MatchRegion>(q).State = EntityState.Modified;
                    }
                    else
                    {
                        m.CityName   = m.AreaName;
                        m.CreateTime = DateTime.Now;
                        m.UpdateTime = DateTime.Now;
                        //db.MatchRegion.Add(m);
                        //db.SaveChanges();
                        var sql = string.Format("INSERT INTO [dbo].[MatchRegion]([ProvinceName],[CityName],[AreaName],[ChefActivityId],[BeginTime],[EndTime],[CreatePerson],[UpdatePerson],[CreateTime],[UpdateTime],[Remark])VALUES('{0}','{1}','{2}',{3},'{4}','{5}','{6}','{7}','{8}','{9}','{10}')", m.ProvinceName, m.CityName, m.AreaName, m.ChefActivityId, m.BeginTime, m.EndTime, m.CreatePerson, m.UpdatePerson, m.CreateTime, m.UpdateTime, m.Remark);

                        dataContext.ExecuteNonQuery(CommandType.Text, sql);
                    }
                }
                db.SaveChanges();
                return("OK");
            }
            catch (Exception)
            {
                return("No");
            }
        }
コード例 #26
0
        public string AddCulLecturerSingle(dynamic requestData)
        {
            try
            {
                CultivateInterflow ci = JsonConvert.DeserializeObject <CultivateInterflow>(JsonConvert.SerializeObject(requestData.Cultivate));

                List <Lecturer> l = JsonConvert.DeserializeObject <List <Lecturer> >(JsonConvert.SerializeObject(requestData.Lecturer));

                ci.UpdateTime   = DateTime.Now;
                ci.UpdatePerson = ci.CreatePerson;

                if (ci.Introduce.IndexOf("base64") > 0)
                {
                    string d = ci.Introduce;

                    foreach (string a in imgHandel.GetHtmlImageUrlList(d))
                    {
                        if (a.IndexOf(ImgHandle.DNS) < 0)
                        {
                            string[] asplit   = a.Split(',');
                            string   imgtype  = asplit[0].Substring(11, asplit[0].Length - 18);
                            string   filepath = imgHandel.Base64StringToImage(asplit[1], imgtype, "/pic/Lecturer");
                            d = d.Replace(a, filepath);
                        }
                    }
                    ci.Introduce = d;
                }


                db.CultivateInterflow.Add(ci);

                db.SaveChanges();

                foreach (Lecturer i in l)
                {
                    i.CuInterId = ci.CuInterId;
                    db.Lecturer.Add(i);
                }
                db.SaveChanges();

                return("OK");
            }
            catch (Exception)
            {
                return("No");
            }
        }
コード例 #27
0
        public string AddTutor(dynamic requestData)
        {
            try
            {
                string addTutor = JsonConvert.SerializeObject(requestData);
                Tutor  model    = JsonConvert.DeserializeObject <Tutor>(addTutor);

                if (model.Introduce.IndexOf("base64") > 0)
                {
                    string d = model.Introduce;
                    GetHtmlImageUrlList(d);
                    foreach (string a in GetHtmlImageUrlList(d))
                    {
                        if (a.IndexOf(ImgHandle.DNS) < 0)
                        {
                            string[] asplit   = a.Split(',');
                            string   imgtype  = asplit[0].Substring(11, asplit[0].Length - 18);
                            string   filepath = Base64StringToImage(asplit[1], imgtype);
                            d = d.Replace(a, filepath);
                        }
                    }
                    model.Introduce = d;
                }
                model.CreateTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;

                model.IsDel = 1;
                db.Tutor.Add(model);
                db.SaveChanges();
                return(model.TutorId.ToString());
            }
            catch (Exception e)
            {
                return("No");
            }
        }
コード例 #28
0
        public string AddChefStarComment(dynamic requestData)
        {
            try
            {
                //增加留言
                string          addDishComment = JsonConvert.SerializeObject(requestData);
                ChefStarComment model          = JsonConvert.DeserializeObject <ChefStarComment>(addDishComment);
                db.ChefStarComment.Add(model);
                db.SaveChanges();


                var q = (from v in db.ChefStarComment
                         where v.ChefStarId == model.ChefStarId
                         select v);

                var lastq = q.OrderByDescending(v => v.CreateTime).Skip(0).Take(3);
                //查找HotelName
                var lastResult = (from v in q
                                  join p in db.OpenIdAssociated on v.OpenId equals p.OpenId
                                  join n in db.RegistMember on p.UserId equals n.MemberId
                                  select new
                {
                    HeadPicUrl = v.HeadPicUrl,
                    MemebName = v.MemberName,
                    Comment = v.Comment,
                    CreateTime = v.CreateTime,
                    HotelName = n.HotelName
                });
                var count = lastResult.Count();
                return("{ \"Count\":\"" + count + "\",\"data\":" + JsonConvert.SerializeObject(lastResult, DateTimeConvent.DateTimehh()) + "}");
            }
            catch (Exception)
            {
                return("{\"Count\":0}");
            }
        }
コード例 #29
0
ファイル: MemberPrizeController.cs プロジェクト: Locdee/ecs
        public string AddMemberPrize(dynamic requestData)
        {
            try
            {
                string             query      = JsonConvert.SerializeObject(requestData);
                List <MemberPrize> memberList = JsonConvert.DeserializeObject <List <MemberPrize> >(query);

                db.MemberPrize.AddRange(memberList);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return("Exc Success");
        }
コード例 #30
0
        public ActionResult UploadDocs(HttpPostedFileBase passport,
                                       HttpPostedFileBase salaryCert)
        {
            string dirName = String.Empty;

            Credit credit;

            using (var context = new CreditContext())
            {
                var credits = context.Credits;

                credit = credits.Where(
                    c => c.UserName == System.Web.HttpContext.Current.User.Identity.Name).OrderByDescending(c => c.DocsFolder).First();

                dirName = credit.DocsFolder;

                var directory = Directory.CreateDirectory(
                    Path.Combine(
                        Server.MapPath(
                            WebConfigurationManager.AppSettings["CreditsRootDirectory"]),
                        dirName));

                var passportDirectory = Directory.CreateDirectory(
                    Path.Combine(directory.FullName, "passport"));

                var salaryCertDirectory = Directory.CreateDirectory(
                    Path.Combine(directory.FullName, "salary_cert"));

                passport.SaveAs(Path.Combine(passportDirectory.FullName,
                                             Path.GetFileName(passport.FileName)));

                salaryCert.SaveAs(Path.Combine(salaryCertDirectory.FullName,
                                               Path.GetFileName(salaryCert.FileName)));

                credit.PassportFile = Directory.GetFiles(
                    Path.Combine(directory.FullName, "passport")).First();

                credit.SalaryCertFile = Directory.GetFiles(
                    Path.Combine(directory.FullName, "salary_cert")).First();

                context.SaveChanges();
            }

            return(RedirectToAction("DocsUploaded", "File"));
        }