Example #1
0
        /// <summary>
        /// 加载清单
        /// </summary>
        /// <param name="infos"></param>
        protected virtual void FillStockItemInventories(IList <StockItemEntity> infos)
        {
            if (infos == null || infos.Count == 0)
            {
                return;
            }
            var productIds =
                infos.Where(it => it.Product != null && it.Product.Id > 0).Select(it => it.Product.Id).ToArray();
            var storehouseIds =
                infos.Where(it => it.Storehouse != null && it.Storehouse.Id > 0).Select(it => it.Storehouse.Id).ToArray();
            var query = new QueryInfo();

            query.Query <InventoryEntity>()
            .Where(it => storehouseIds.Contains(it.Storehouse.Id) && productIds.Contains(it.Product.Id));
            var inventories = Repository.Gets <InventoryEntity>(query);

            if (inventories != null)
            {
                foreach (var info in infos)
                {
                    if (info.Product == null || info.Storehouse == null)
                    {
                        continue;
                    }
                    info.Inventory =
                        inventories.FirstOrDefault(
                            it => it.Product.Id == info.Product.Id && it.Storehouse.Id == info.Storehouse.Id);
                }
            }
        }
Example #2
0
 public void DeleteEducation()
 {
     var repo = new Repository<EducationModel>(DbCollection.Education);
     var contacts = repo.Gets().Where(m => m.UserId == "5709a5b24a549a1a9873a19b");
     foreach (var item in contacts)
     {
         repo.Delete(item.Id);
     }
 }
Example #3
0
        public static bool AddCountryHelper(CountryModel model)
        {
            var repo = new Repository<CountryModel>(DbCollection.Country);
            if (repo.Gets().Any(m => m.Name.Equals(model.Name)))
            {
                return false;
            }

            repo.Insert(model);
            return true;
        }
        public FileResult DownloadAlonhadat()
        {
            var repo = new Repository<AlonhadatReport>("alonhadatreports");
            var data = repo.Gets().OrderBy(i => i.Date);
            var csv = new StringBuilder();
            csv.AppendLine("Date,Vip1,Vip2,Vip3,Vip4,Vip5,Basic,Total");

            foreach (var item in data)
            {
                csv.AppendLine(item.Csv);
            }
            return File(new System.Text.UTF8Encoding().GetBytes(csv.ToString()), "text/csv", "alonhadat.com.vn.csv");
        }
 public JsonResult Diaoconline()
 {
     var repo = new Repository<DiaOcOnlineReport>("diaoconlinereports");
     return Json(repo.Gets().OrderBy(i => i.Date).Select(i => new
     {
         date = TimeZoneInfo.ConvertTimeToUtc(i.Date, TimeZoneInfo.Local).ToShortDateString() + " (" + i.Count + ")",
         count = i.Count,
         vip = i.Vip,
         tietkiem = i.TietKiem,
         tienloi = i.TienLoi,
         hieuqua = i.HieuQua,
         basic = i.Basic
     }), JsonRequestBehavior.AllowGet);
 }
 public JsonResult Cafeland()
 {
     var repo = new Repository<CafelandReport>("cafelandreports");
     return Json(repo.Gets().OrderBy(i => i.Date).Select(i => new
     {
         date = TimeZoneInfo.ConvertTimeToUtc(i.Date, TimeZoneInfo.Local).ToShortDateString() + " (" + i.Count + ")",
         count = i.Count,
         supervip = i.SuperVip,
         vip1 = i.Vip1,
         vip2 = i.Vip2,
         vip3 = i.Vip3,
         basic = i.Basic
     }), JsonRequestBehavior.AllowGet);
 }
 public JsonResult Batdongsan()
 {
     var repo = new Repository<BdsReport>("bdsreports");
     return Json(repo.Gets().OrderBy(i => i.Date).Select(i => new
     {
         date = TimeZoneInfo.ConvertTimeToUtc(i.Date, TimeZoneInfo.Local).ToShortDateString() + " (" + i.Count + ")",
         count = i.Count,
         specialvip = i.SpecialVip,
         vip1 = i.Vip1,
         vip2 = i.Vip2,
         vip3 = i.Vip3,
         basic = i.Basic
     }), JsonRequestBehavior.AllowGet);
 }
 public JsonResult Alonhadat()
 {
     var repo = new Repository<AlonhadatReport>("alonhadatreports");
     return Json(repo.Gets().OrderBy(i => i.Date).Select(i => new
     {
         date = TimeZoneInfo.ConvertTimeToUtc(i.Date, TimeZoneInfo.Local).ToShortDateString() + " (" + i.Count + ")",
         count = i.Count,
         vip1 = i.Vip1,
         vip2 = i.Vip2,
         vip3 = i.Vip3,
         vip4 = i.Vip4,
         vip5 = i.Vip5,
         basic = i.Basic
     }), JsonRequestBehavior.AllowGet);
 }
 /// <summary>
 /// 加载清单
 /// </summary>
 /// <param name="info"></param>
 protected virtual void LoadInventory(PurchaseItemEntity info)
 {
     if (info.Inventory == null && info.Purchase != null && info.Product != null)
     {
         LoadPurchase(info);
         if (info.Purchase == null || info.Purchase.Storehouse == null)
         {
             return;
         }
         var query = new QueryInfo();
         query.Query <InventoryEntity>()
         .Where(it => it.Storehouse.Id == info.Purchase.Storehouse.Id && it.Product.Id == info.Product.Id);
         var inventories = Repository.Gets <InventoryEntity>(query);
         if (inventories != null)
         {
             info.Inventory = inventories.FirstOrDefault();
         }
     }
 }
Example #10
0
 public void FixErrorDefaultData()
 {
     var repo = new Repository<UserModel>(DbCollection.User);
     var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
     var users = repo.Gets().ToList();
     Console.WriteLine("BEGIN INSERT MISSING DATA...");
     foreach (var user in users)
     {
         Console.WriteLine("CHECK ShareSetting: " + user.UserName);
         var shareSetting = repoShare.Gets().FirstOrDefault(m => m.UserId.Equals(user.Id.ToString()));
         if (shareSetting == null)
         {
             Console.WriteLine("BEGIN INSERT ShareSetting: " + user.UserName);
             repoShare.Insert(new ShareSettingModel { UserId = user.Id.ToString() });
         }
     }
     Console.WriteLine("DONE!!!!");
     Console.ReadLine();
 }
Example #11
0
        /// <summary>
        /// 验证锁库存
        /// </summary>
        /// <param name="info"></param>
        /// <param name="dataEntity"></param>
        /// <returns></returns>
        protected virtual bool ValidateLockCount(StockItemEntity info, StockItemEntity dataEntity)
        {
            info.Stock = dataEntity != null
                            ? Repository.Get <StockEntity>(dataEntity.Stock.Id)
                            : info.Stock != null && info.Stock.SaveType == SaveType.Add
                                  ? info.Stock
                                  : Repository.Get <StockEntity>(info.Stock.Id);

            var count = dataEntity == null ? info.Count : dataEntity.Count;

            if (count > 0)
            {
                return(true);
            }
            if (!info.IsLockCount())
            {
                return(true);
            }
            info.Product    = dataEntity != null ? dataEntity.Product : info.Product;
            info.Storehouse = dataEntity != null ? dataEntity.Storehouse : info.Storehouse;
            if (info.Product != null && info.Storehouse != null)
            {
                var query = new QueryInfo();
                query.Query <InventoryEntity>()
                .Where(it => it.Storehouse.Id == info.Storehouse.Id && it.Product.Id == info.Product.Id);
                var inventories = Repository.Gets <InventoryEntity>(query);
                if (inventories != null)
                {
                    info.Inventory = inventories.FirstOrDefault();
                }
            }
            if (info.Inventory == null)
            {
                return(true);
            }
            if (info.Inventory.EnableCount < Math.Abs(count))
            {
                info.AddErrorByName(typeof(InventoryEntity).FullName, "EnoughCount");
                return(false);
            }
            return(true);
        }
Example #12
0
 /// <summary>
 /// 加载清单
 /// </summary>
 /// <param name="info"></param>
 protected virtual void LoadInventory(StockItemEntity info)
 {
     if (info.Inventory == null)
     {
         LoadDataEntity(info);
         var product    = info.DataEntity != null ? info.DataEntity.Product : info.Product;
         var storehouse = info.DataEntity != null ? info.DataEntity.Storehouse : info.Storehouse;
         if (product != null && storehouse != null)
         {
             var query = new QueryInfo();
             query.Query <InventoryEntity>()
             .Where(it => it.Storehouse.Id == storehouse.Id && it.Product.Id == product.Id);
             var inventories = Repository.Gets <InventoryEntity>(query);
             if (inventories != null)
             {
                 info.Inventory = inventories.FirstOrDefault();
             }
         }
     }
 }
        public ActionResult Create(AdminSetting model)
        {
            try
            {
                var repo = new Repository<AdminSetting>(DbCollection.AdminSetting);
                var item = repo.Gets().FirstOrDefault(m => m.Title.Equals(model.Title));
                if (item == null)
                {
                    model.Enable = true;
                    repo.Insert(model);
                    return RedirectToAction("Index");
                }
                else
                {
                    return Json(new { result = MyConstants.Duplicate });
                }

            }
            catch
            {
                return View();
            }
        }
        /// <summary>
        /// 加载清单
        /// </summary>
        /// <param name="purchase"></param>
        /// <param name="infos"></param>
        protected virtual void FillPurchaseItemInventories(PurchaseEntity purchase, IList <PurchaseItemEntity> infos)
        {
            if (infos == null || infos.Count == 0)
            {
                return;
            }
            LoadDataEntity(purchase);
            var storehouse = purchase.DataEntity == null ? purchase.Storehouse : purchase.DataEntity.Storehouse;

            if (storehouse == null)
            {
                return;
            }
            purchase.Storehouse = storehouse;
            var productIds =
                infos.Where(it => it.Product != null && it.Product.Id > 0).Select(it => it.Product.Id).ToArray();
            var query = new QueryInfo();

            query.Query <InventoryEntity>()
            .Where(it => it.Storehouse.Id == storehouse.Id && productIds.Contains(it.Product.Id));
            var inventories = Repository.Gets <InventoryEntity>(query);

            if (inventories != null)
            {
                foreach (var info in infos)
                {
                    if (info.Product == null)
                    {
                        continue;
                    }
                    info.Inventory =
                        inventories.FirstOrDefault(
                            it => it.Product.Id == info.Product.Id);
                }
            }
        }
        /// <summary>
        /// 加载用户
        /// </summary>
        /// <param name="infos"></param>
        protected virtual void FillPurchaseItemProducts(IList <PurchaseItemEntity> infos)
        {
            var productIds =
                infos.Where(it => it.Product != null && it.Product.Id > 0).Select(it => it.Product.Id).ToArray();
            var query = new QueryInfo();

            query.Query <ProductEntity>()
            .Where(it => productIds.Contains(it.Id)).Select(it => new object[] { it, it.Inventories.Select(s => s) });
            var products = Repository.Gets <ProductEntity>(query);

            if (products != null)
            {
                foreach (var info in infos)
                {
                    if (info.Product == null)
                    {
                        continue;
                    }
                    info.Product =
                        products.FirstOrDefault(
                            it => it.Id == info.Product.Id);
                }
            }
        }
 public ActionResult TranslationExpertise()
 {
     var repo = new Repository<ProfileExpertiseModel>(DbCollection.ProfileExpertise);
     var listItem = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1) & m.ExpertiseId != null).ToList();
     var itemOrther = repo.Gets().FirstOrDefault(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1) & m.ExpertiseId == null) ??
                new ProfileExpertiseModel();
     var repoExpertise = new Repository<ExpertiseModel>(DbCollection.Expertise);
     var listExpertise = repoExpertise.Gets().ToList();
     var model = new ProfileTranslationViewModel
     {
         ProfileExpertiseList = listItem,
         ExpertiseList = listExpertise,
         ExpertiseOther = itemOrther.Expertise
     };
     return PartialView("_ProfileTranslationExpertisePartial", model);
 }
 public ActionResult InterpreterMainLanguagePairLoad()
 {
     var repo = new Repository<ProfileLanguageModel>(DbCollection.ProfileLanguage);
     var listItem = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(2)).ToList();
     var model = new ProfileInterpreterViewModel
     {
         ProfileLanguageList = listItem,
     };
     return PartialView("_ProfileInterpreterMainLanguagePairLoadPartial", model);
 }
 public ActionResult TranslationBestRate()
 {
     var repo = new Repository<ProfileTranslationRateModel>(DbCollection.ProfileTranslationRate);
     var item = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId())).OrderByDescending(i => i.Id).FirstOrDefault() ??
                new ProfileTranslationRateModel();
     var model = new ProfileTranslationViewModel
     {
         ProfileRate = item,
         MinRatePerSourceWordList = new SelectList(MyConstants.MinRatePerSourceWordList(), "Name", "Name"),
         PreferredRatePerSourceWordList = new SelectList(MyConstants.PreferredRatePerSourceWordList(), "Name", "Name"),
         MinRatePerHourList = new SelectList(MyConstants.MinRatePerHourList(), "Name", "Name"),
         PreferredRatePerHourList = new SelectList(MyConstants.PreferredRatePerHourList(), "Name", "Name"),
     };
     return PartialView("_ProfileTranslationRatePartial", model);
 }
        public ActionResult TranslationWordTranslated(ProfileTranslationViewModel model)
        {
            var repo = new Repository<ProfileTotalWordModel>(DbCollection.ProfileTotalWord);
            var item = repo.Gets().FirstOrDefault(m => m.Id.Equals(model.ProfileTotalWord.Id));
            if (item != null)
            {
                item.TotalWord = model.ProfileTotalWord.TotalWord;
                repo.Update(item);
            }
            else
            {
                item = new ProfileTotalWordModel
                {
                    AccountId = User.Identity.GetUserId(),
                    TotalWord = model.ProfileTotalWord.TotalWord,
                    Type = 1
                };
                repo.Insert(item);
            }

            return Json(new { result = true, model });
        }
 public ActionResult TranslationSince(ProfileTranslationViewModel model)
 {
     var repo = new Repository<ProfileSinceModel>(DbCollection.ProfileSince);
     var item = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1)).OrderByDescending(i => i.Id).FirstOrDefault();
     if (item != null)
     {
         item.Since = model.ProfileSince.Since;
         repo.Update(item);
     }
     else
     {
         item = new ProfileSinceModel
         {
             AccountId = User.Identity.GetUserId(), 
             Since = model.ProfileSince.Since, 
             Type = 1
         };
         repo.Insert(item);
     }
     
     return Json(new { result = true, model });
 }
        //[ValidateAntiForgeryToken]
        public ActionResult TranslationTool(ProfileTranslationViewModel model)
        {
            var repo = new Repository<ProfileToolModel>(DbCollection.ProfileTool);
            var listItem = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1)).ToList();
            foreach (var item in listItem)
            {
                repo.Delete(item.Id);
            }
            foreach (var item in model.ProfileToolList)
            {
                item.AccountId = User.Identity.GetUserId();
                item.Type = 1;
                repo.Insert(item);
            }
            if (string.IsNullOrEmpty(model.ToolOther))
                return Json(new { result = true, model });

            var other = new ProfileToolModel
            {
                AccountId = User.Identity.GetUserId(),
                Type = 1,
                Tool = model.ToolOther
            };
            repo.Insert(other);

            return Json(new { result = true, model });
        }
Example #22
0
 public static List <T> Gets(string commaDelimitedIds)
 {
     return(Repository.Gets(commaDelimitedIds));
 }
Example #23
0
 public static List <T> Gets(ILinqContext <T> context, t[] ids)
 {
     return(Repository.Gets(context, ids));
 }
 // GET: SettingAdmin
 public ActionResult Index()
 {
     var repo = new Repository<AdminSetting>(DbCollection.AdminSetting);
     var listItem = repo.Gets().ToList();
     return View(listItem);
 }
        public JsonResult LoadContact()
        {
            String searc = Request.QueryString["search[value]"];
           var repo = new Repository<ContactMarkettingModel>("contactMarketting");
            var datax = repo.Gets().Select(i => new
            {

                name = i.Name,
                objecttitle = i.ObjectTitle,
                tel = i.Tel,
                email = i.Email,
                date = i.date
            });
            JsonPage page=new JsonPage();
            String pageindex=   Request.QueryString["draw"];
            int pagesize = 10;
            page.recordsTotal = datax.ToList().Count;



            page.recordsFiltered = datax.ToList().Count;
            page.draw = int.Parse(pageindex);
            String lg = Request.QueryString["length"];
            String begin = Request.QueryString["start"];
            datax = datax.Skip(int.Parse(begin)).Take(int.Parse(lg));
            page.data = datax;


            var data = Json(page, JsonRequestBehavior.AllowGet);



            return data;

        }
        public async Task<JsonResult> Post(ContactMarkettingModel model)
        {
            //validate data
            if (!ModelState.IsValid) return Json(false);

            #region log it

            var log = log4net.LogManager.GetLogger("mbnd");
            log.Info(JsonConvert.SerializeObject(model, Formatting.Indented));

            #endregion

            #region storeDb

            var repo = new Repository<ContactMarkettingModel>("contactMarketting");
            var data = repo.Gets().Where(i => i.Email == model.Email).ToList();
            if (data.Count>0)
            {
                JsonPage page = new JsonPage();
                page.T = 1;
                return Json(page,JsonRequestBehavior.AllowGet);
            }
            else
            {
                repo.Insert(model);
            }
           

            #endregion

   

            #region Send Email

            //try
            //{
            //    if (!String.IsNullOrEmpty(model.EmailCustomer))
            //    {
            //        var mMess = new MailMessage
            //        {
            //            From = new MailAddress(ConfigurationManager.AppSettings["Gmail"])
            //        };
            //        mMess.To.Add(new MailAddress(model.EmailCustomer));

            //        mMess.Subject = "Lead muabannhadat.vn " + model.Name;
            //        mMess.IsBodyHtml = true;
            //        mMess.Body = RenderRazorViewToString("TemplateEmail", model);
            //        var smClt = new SmtpClient {EnableSsl = true};
            //        smClt.Send(mMess);
            //        return Json(true);
            //    }
            //}
            //catch
            //{
            //    return Json(false);
            //}

            #endregion

            return Json(true);
        }
Example #27
0
 public static List <T> Gets(ILinqContext <T> context, string commaDelimitedIds)
 {
     return(Repository.Gets(context, commaDelimitedIds));
 }
Example #28
0
 public static List <T> Gets(QueryCondition q)
 {
     return(Repository.Gets(q));
 }
 public ActionResult TranslationToolLoad()
 {
     var repo = new Repository<ProfileToolModel>(DbCollection.ProfileTool);
     var listItem = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1)).ToList();
     var model = new ProfileTranslationViewModel
     {
         ProfileToolList = listItem,
     };
     return PartialView("_ProfileTranslationToolLoadPartial", model);
 }
 public ActionResult TranslationTool()
 {
     var repo = new Repository<ProfileToolModel>(DbCollection.ProfileTool);
     var listItem = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1) & m.ToolId != null).ToList();
     var itemOrther = repo.Gets().FirstOrDefault(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1) & m.Tool == null) ??
                new ProfileToolModel();
     var repoTool = new Repository<ToolModel>(DbCollection.Tool);
     var listTool = repoTool.Gets().ToList();
     var model = new ProfileTranslationViewModel
     {
         ProfileToolList = listItem,
         ToolList = listTool,
         ExpertiseOther = itemOrther.Tool
     };
     return PartialView("_ProfileTranslationToolPartial", model);
 }
 public ActionResult InterpreterType()
 {
     var repo = new Repository<ProfileInterpreterTypeModel>(DbCollection.ProfileInterpreterType);
     var listItem = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.TypeId != null).ToList();
     var itemOrther = repo.Gets().FirstOrDefault(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.TypeId == null) ??
                new ProfileInterpreterTypeModel();
     var repoExpertise = new Repository<InterpreterTypeModel>(DbCollection.InterpreterType);
     var listExpertise = repoExpertise.Gets().ToList();
     var model = new ProfileInterpreterViewModel
     {
         ProfileInterpreterTypeList = listItem,
         InterpreterTypeList = listExpertise,
         InterpreterTypeOther = itemOrther.Type
     };
     return PartialView("_ProfileInterpreterTypePartial", model);
 }
 public ActionResult TranslationSince()
 {
     var repo = new Repository<ProfileSinceModel>(DbCollection.ProfileSince);
     var item = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1)).OrderByDescending(i => i.Id).FirstOrDefault();
     var model = new ProfileTranslationViewModel
     {
         ProfileSince = item,
         SinceList = new SelectList(MyConstants.SinceList(), "Name", "Name")
     };
     return PartialView("_ProfileTranslationSincePartial", model);
 }
        //[ValidateAntiForgeryToken]
        public ActionResult InterpreterExpertise(ProfileInterpreterViewModel model)
        {
            var repo = new Repository<ProfileExpertiseModel>(DbCollection.ProfileExpertise);
            var listItem = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(2)).ToList();
            foreach (var item in listItem)
            {
                repo.Delete(item.Id);
            }
            foreach (var item in model.ProfileExpertiseList)
            {
                item.AccountId = User.Identity.GetUserId();
                item.Type = 2;
                repo.Insert(item);
            }
            if (string.IsNullOrEmpty(model.ExpertiseOther))
                return Json(new { result = true, model });

            var other = new ProfileExpertiseModel
            {
                AccountId = User.Identity.GetUserId(),
                Type = 2,
                Expertise = model.ExpertiseOther
            };
            repo.Insert(other);

            return Json(new { result = true, model });
        }
 public ActionResult TranslationWordTranslated()
 {
     var repo = new Repository<ProfileTotalWordModel>(DbCollection.ProfileTotalWord);
     var item = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1)).OrderByDescending(i => i.Id).FirstOrDefault();
     var model = new ProfileTranslationViewModel
     {
         ProfileTotalWord = item
     };
     return PartialView("_ProfileTranslationWordTranslatedPartial", model);
 }
 public ActionResult InterpreterSinceLoad()
 {
     var repo = new Repository<ProfileSinceModel>(DbCollection.ProfileSince);
     var item = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(2)).OrderByDescending(i => i.Id).FirstOrDefault() ??
                new ProfileSinceModel();
     var model = new ProfileInterpreterViewModel
     {
         ProfileSince = item
     };
     return PartialView("_ProfileInterpreterSinceLoadPartial", model);
 }
 public ActionResult TranslationBestRateLoad()
 {
     var repo = new Repository<ProfileTranslationRateModel>(DbCollection.ProfileTranslationRate);
     var item = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId())).OrderByDescending(i => i.Id).FirstOrDefault() ??
                new ProfileTranslationRateModel();
     var model = new ProfileTranslationViewModel
     {
         ProfileRate = item
     };
     return PartialView("_ProfileTranslationRateLoadPartial", model);
 }
 public ActionResult ProfileResidence()
 {
     var login = UserManager.FindByIdAsync(User.Identity.GetUserId());
     var repo = new Repository<CountryModel>("Country");
     var countries = repo.Gets().OrderBy(i => i.Name);
     var model = new ProfileResidenceViewModel
     {
         Country = login.Result.FirstName,
         CountryId = login.Result.CountryId,
         StateCity = login.Result.StateCity,
         CountryList = new SelectList(countries, "Id", "Name")
     };
     return PartialView("_ProfileResidencePartial", model);
 }
        public ActionResult TranslationBestRate(ProfileTranslationViewModel model)
        {
            var repo = new Repository<ProfileTranslationRateModel>(DbCollection.ProfileTranslationRate);
            var item = repo.Gets().FirstOrDefault(m => m.Id.Equals(model.ProfileRate.Id));
            if (item != null)
            {
                item.MinRatePerSourceWord = model.ProfileRate.MinRatePerSourceWord;
                item.PreferredRatePerSourceWord = model.ProfileRate.PreferredRatePerSourceWord;
                item.MinRatePerHour = model.ProfileRate.MinRatePerHour;
                item.PreferredRatePerHour = model.ProfileRate.PreferredRatePerHour;
                repo.Update(item);
            }
            else
            {
                item = new ProfileTranslationRateModel
                {
                    AccountId = User.Identity.GetUserId(),
                    MinRatePerSourceWord = model.ProfileRate.MinRatePerSourceWord,
                    PreferredRatePerSourceWord = model.ProfileRate.PreferredRatePerSourceWord,
                    MinRatePerHour = model.ProfileRate.MinRatePerHour,
                    PreferredRatePerHour = model.ProfileRate.PreferredRatePerHour,
                };
                repo.Insert(item);
            }

            return Json(new { result = true, model });
        }
 public ActionResult TranslationMainLanguagePair()
 {
     var repo = new Repository<ProfileLanguageModel>(DbCollection.ProfileLanguage);
     var listItem = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1) & m.SourceLanguageId != null).ToList();
     var itemOrther = repo.Gets().FirstOrDefault(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1) & m.SourceLanguageId == null) ??
                new ProfileLanguageModel();
     var repoLanguage = new Repository<LanguageModel>(DbCollection.Language);
     var listLanguage = repoLanguage.Gets().ToList();
     var model = new ProfileTranslationViewModel
     {
         ProfileLanguageList = listItem,
         LanguageList = new SelectList(listLanguage, "Id", "Name"),
         SourceOther = itemOrther.SourceLanguage,
         TargetOther = itemOrther.TargetLanguage,
     };
     return PartialView("_ProfileTranslationMainLanguagePairPartial", model);
 }
Example #40
0
 /// <summary>
 /// get obj list
 /// </summary>
 public static List <T> Gets(t[] ids)
 {
     return(Repository.Gets(ids));
 }
        //[ValidateAntiForgeryToken]
        public ActionResult TranslationMainLanguagePair(ProfileTranslationViewModel model)
        {
            var repo = new Repository<ProfileLanguageModel>(DbCollection.ProfileLanguage);
            var listItem = repo.Gets().Where(m => m.AccountId.Equals(User.Identity.GetUserId()) && m.Type.Equals(1)).ToList();
            foreach (var profileLanguageModel in listItem)
            {
                repo.Delete(profileLanguageModel.Id);
            }
            foreach (var item in model.ProfileLanguageList)
            {
                item.AccountId = User.Identity.GetUserId();
                item.Type = 1;
                repo.Insert(item);
            }
            if (string.IsNullOrEmpty(model.SourceOther) || string.IsNullOrEmpty(model.TargetOther))
                return Json(new {result = true, model});

            var other = new ProfileLanguageModel
            {
                AccountId = User.Identity.GetUserId(),
                Type = 1,
                SourceLanguage = model.SourceOther,
                TargetLanguage = model.TargetOther,
            };
            repo.Insert(other);

            return Json(new { result = true, model });
        }