public ResultDto Execute(int?ParentId, string name) { if (string.IsNullOrWhiteSpace(name)) { return(new ResultDto { IsSuccess = false, Message = "نام را وارد کنید", }); } SCategory sCategory = new SCategory { Name = name, ParentCategory = _context.SCategories.Find(ParentId), }; _context.SCategories.Add(sCategory); _context.SaveChanges(); return(new ResultDto { IsSuccess = true, Message = "دسته بندی با موفقیت اضافه گردید", }); }
public ActionResult Filter(string filter) { if (!string.IsNullOrEmpty(filter) && filter.EndsWith("or ")) { filter = " and " + ReplaceLastOccurrence(filter, "or", ""); } if (!string.IsNullOrEmpty(filter) && filter.EndsWith("and ")) { filter = " and " + ReplaceLastOccurrence(filter, "and", ""); } SProject sproject = new SProject(); int pagenumber = 1; //int.Parse( Request.QueryString.Get("pagenumber")); int itemsperpage = 50; // int.Parse(Request.QueryString.Get("itemsperpage")); string conditions = " where iduser='******' " + filter + "; "; //Request.QueryString.Get("conditions"); string order = Request.QueryString.Get("order"); SCategory scat = new SCategory(); List <Persistence.Entities.Project> lista = sproject.GetListPaged(pagenumber, itemsperpage, conditions, order); List <Models.Project> listprojects = lista.Select(e => new Models.Project().InjectFrom(e)).Cast <Models.Project>().ToList(); if (((RegisterBindingModel)SessionBag.Current.User).Freelance) { return(PartialView("PartialFilterOffer", listprojects)); } else { return(PartialView("PartialFilterOffer", listprojects)); } }
public ActionResult Edit(int id) { var viewModel = Mapper.Map <Item, ItemViewModel>(SItem.SelectById(id)); viewModel.Items = Mapper.Map <IEnumerable <Category>, IEnumerable <SelectListItem> >(SCategory.GetAllCategories()); return(View(viewModel)); }
private void tabControl1_Selected(object sender, TabControlEventArgs e) { _currentTab = e.TabPage.Tag.ToString(); switch (_currentTab) { case "GENERAL": butSave.Enabled = true; butSave.Text = "Save General Info"; break; case "CONSUMPTION": butSave.Enabled = true; butSave.Text = "Save Service"; if (!_contabSelected) { DataUsageEnum duenum = (DataUsageEnum)Enum.Parse(typeof(DataUsageEnum), _forecastInfo.DataUsage); switch (duenum) { case DataUsageEnum.DATA_USAGE1: SDataUsage ctr = new SDataUsage(_forecastInfo); // ctr.OnDataUsageEdit += new EventHandler(ctr_OnDataUsageEdit); ctr.ForecastInfoDataChanged += new EventHandler <EventArgs>(ctr_ForecastInfoDataChanged); ctr.Dock = DockStyle.Fill; tabConsumption.Controls.Add(ctr); break; case DataUsageEnum.DATA_USAGE2: SReported ctr1 = new SReported(_forecastInfo); // ctr1.ForecastInfoDataChanged += new EventHandler<EventArgs>(ctr_ForecastInfoDataChanged); ctr1.ForecastInfoDataChanged += new EventHandler <EventArgs>(ctr_ForecastInfoDataChanged); ctr1.Dock = DockStyle.Fill; tabConsumption.Controls.Add(ctr1); break; case DataUsageEnum.DATA_USAGE3: SCategory ctr2 = new SCategory(_forecastInfo); // ctr2.ForecastInfoDataChanged += new EventHandler<EventArgs>(ctr_ForecastInfoDataChanged); ctr2.ForecastInfoDataChanged += new EventHandler <EventArgs>(ctr_ForecastInfoDataChanged); ctr2.Dock = DockStyle.Fill; tabConsumption.Controls.Add(ctr2); break; } _contabSelected = true; } break; case "REPORT": butSave.Enabled = false; break; } }
// GET: Offer/Create public ActionResult Create() { try { if (SessionBag.Current.User != null) { SCategory scate = new SCategory(); Models.Offer offer = new Models.Offer(); offer.Categories = scate.FindAll(); //Request.Referrer.ToString() ViewBag.UrlRef = Request.UrlReferrer.LocalPath; offer.DateIniPhase1 = DateTime.Now.Date; offer.DateEndPhase1 = DateTime.Now.Date; offer.DateIniPhase2 = DateTime.Now.Date; offer.DateEndPhase2 = DateTime.Now.Date; offer.DateIniPhase3 = DateTime.Now.Date; offer.DateEndPhase3 = DateTime.Now.Date; offer.DateIniPhase4 = DateTime.Now.Date; offer.DateEndPhase4 = DateTime.Now.Date; ViewBag.IdUser = SessionBag.Current.User.Id; return(View(offer)); } else { //offerp.IdUser = "******"; return(RedirectToAction("Index", "Home")); //throw new Exception("Favor iniciar sesion con usuario y password "); } } catch (Exception er) { Log4NetLogger logger2 = new Log4NetLogger(); logger2.CurrentUser = SessionBag.Current.User.Id; if (Request != null) { logger2.Error(er, Request.Path, Request.RawUrl); throw new Exception(er.Message); } else { logger2.Error(er); } } return(RedirectToAction("Index", "Home")); }
public ActionResult GetByCategory(int categoryId) { var list = new List <ItemsListViewModel>(); foreach (var item in SItem.GetByCategory(categoryId)) { list.Add(new ItemsListViewModel() { CategoryName = SCategory.SelectById(item.CategoryId).Name, Name = item.Name, Quantity = item.Quantity, Value = item.Value, Id = item.Id }); } return(View(list)); }
// GET: Categories public ActionResult Index() { var list = new List <ItemsListViewModel>(); foreach (var item in SItem.GetAllItems()) { var category = SCategory.SelectById(item.CategoryId); list.Add(new ItemsListViewModel() { CategoryName = category == null ? string.Empty : category.Name, Name = item.Name, Quantity = item.Quantity, Value = item.Value, Id = item.Id }); } return(View(list)); }
// GET: Offer/Edit/5 public ActionResult Edit(int id) { SOffer soffer = new SOffer(); Persistence.Entities.Offer offer = soffer.GetById(id); Models.Offer offerm = new Models.Offer(); SCategory scate = new SCategory(); offerm.Categories = scate.FindAll(); offerm.InjectFrom(offer); offerm.Category = new Models.Category(); offerm.Category.InjectFrom(offer.Category); AddOfferPhasesToOffer(offer, offerm); ViewBag.UrlRef = Request.UrlReferrer.LocalPath; ViewBag.IdUser = SessionBag.Current.User.Id; return(View(offerm)); }
public ResponseBase UpdateSystem(CategoryModel menuCategory, int userId) { using (var db = new IEDEntities()) { ResponseBase result = null; try { result = new ResponseBase(); SCategory category = db.SCategories.FirstOrDefault(x => x.Id == menuCategory.Id && !x.IsDeleted); if (category != null) { category.Position = menuCategory.Position; category.OrderIndex = menuCategory.OrderIndex; if (menuCategory.Icon != "0" && menuCategory.Icon != null) { category.Icon = menuCategory.Icon.Split(',').ToList().FirstOrDefault(); } category.UpdatedUser = userId; category.UpdatedDate = DateTime.Now; db.Entry <SCategory>(category).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); result.IsSuccess = true; } else { result.IsSuccess = false; result.Errors.Add(new Error() { MemberName = "Cập Nhật Nhóm Danh Mục", Message = "Nhóm Danh Mục đang thao tác không tồn tại. Vui lòng kiểm tra lại!" }); } } catch (Exception ex) { throw ex; } return(result); } }
public ActionResult Create() { var viewModel = new ItemViewModel { Items = Mapper.Map <IEnumerable <Category>, IEnumerable <SelectListItem> >(SCategory.GetAllCategories()) }; return(View(viewModel)); }
// GET: Project public ActionResult Index(string id) { int statusProject = 0; if (Request.QueryString["statusProject"] != null) { statusProject = int.Parse(Request.QueryString["statusProject"]); } ViewBag.Status = statusProject; SOffer soffer = new SOffer(); int pagenumber = 1; //int.Parse( Request.QueryString.Get("pagenumber")); int itemsperpage = 50; // int.Parse(Request.QueryString.Get("itemsperpage")); string conditions = ""; ZonaFl.Persistence.Entities.AspNetUsers useru = null; ZonaFl.Business.SubSystems.SUser usern = new Business.SubSystems.SUser(); useru = usern.GetUserById(new Guid(id)); if (SessionBag.Current.User == null) { SessionBag.Current.User = useru; } //if (statusProject == 2 && !useru.Freelance) // statusProject = 1; // Publicada = 0, //EnCurso = 1, //Finalizada = 2, //Eliminada = 3 if (statusProject == 0) { if (!useru.Freelance) { //conditions = " where O.Id NOT IN(SELECT Project.idoffer from project) and O.iduser='******' and (OP.StatusPhase=" + statusProject + " "; //Request.QueryString.Get("conditions"); conditions = " where O.Id NOT IN(SELECT Project.idoffer from project) and (O.iduser='******' and O.Status=0"; //and (OP.StatusPhase=" + statusProject + " "; //Request.QueryString.Get("conditions"); } else { conditions = " where O.Id NOT IN(SELECT Project.idoffer from project) and (OU.iduser='******' and O.Status=0";// and (OP.StatusPhase=" + statusProject + " "; //Request.QueryString.Get("conditions"); } } else if (statusProject >= 1) { if (!useru.Freelance) { conditions = " where O.IdUser = '******' and (project.Status = " + statusProject + " OR O.Status=" + statusProject; //conditions = " where O.Id IN(SELECT Project.idoffer from project) and (O.iduser='******' and project.Status="+ statusProject; } else { //conditions = " where O.IdUser = '******' and project.Status = " + statusProject; conditions = " where O.Id IN(SELECT Project.idoffer from project where project.Status=" + statusProject + ") and (OU.iduser='******'"; //Request.QueryString.Get("conditions"); } } ///user session bag ZonaFl.Business.SubSystems.SProject userp = new Business.SubSystems.SProject(); var projects = userp.GetProjectsEndedByUser(id); List <Models.Project> projetsm = new List <Models.Project>(); projetsm = projects.Select(e => new Models.Project().InjectFrom(e)).Cast <Models.Project>().ToList(); projetsm.Select(e => new Models.Project().InjectFrom(usern.GetUserByOffer(e.IdOffer, 1))).Cast <Models.Project>().ToList(); ViewBag.Commentaries = projetsm; int calif = userp.GetCalificationAverageUser(id); //calif = 3; ViewBag.Calification = calif; RegisterBindingModel regbm = new RegisterBindingModel(); regbm.InjectFrom(useru); regbm.Skills = useru.Skills.Select(e => new ZonaFl.Models.Skill().InjectFrom(e)).Cast <ZonaFl.Models.Skill>().ToList(); SessionBag.Current.User = regbm; ViewBag.IdUser = id; ViewBag.NameUser = regbm.UserName; ViewBag.User = useru.UserName; ViewBag.ImageUser = useru.Image; ViewBag.EmailUserBuyer = regbm.Email; ViewBag.EmailConfirmed = (useru.EmailConfirmed)? @"verified": @""; ViewBag.PagosConfirmed = (useru.PagosConfirmed) ? @"verified" : @""; // ViewBag.MobileConfirmed= ///// string order = Request.QueryString.Get("order"); SCategory scat = new SCategory(); List <ZonaFl.Persistence.Entities.Category> listcat = scat.FindAll(); ViewBag.Categories = listcat; List <Persistence.Entities.Offer> lista = new List <Persistence.Entities.Offer>(); if (!regbm.Freelance) { //if (statusProject == 0) //{ // conditions += " or OP.StatusPhase =" + 1+")"; //} //else //{ conditions += " )"; //} lista = soffer.GetListPaged(pagenumber, itemsperpage, conditions + ";", order, statusProject); } else { conditions += " )"; lista = soffer.GetAppliedOfferByUserListPaged(pagenumber, itemsperpage, conditions, order); } List <Models.Offer> listoffers = lista.Select(e => new Models.Offer().InjectFrom(e)).Cast <Models.Offer>().ToList(); SProject spro = new SProject(); listoffers.ForEach(e => e.Comments = spro.GetByOffer(e.Id) != null ? spro.GetByOffer(e.Id).Comments : ""); listoffers.ForEach(e => e.Qualification = spro.GetByOffer(e.Id) != null ? spro.GetByOffer(e.Id).Qualification : 0); if (statusProject == 1) { listoffers.ForEach(e => e.IsForFinally = spro.IsProjectForFinally(e.Id)); } List <Persistence.Entities.Category> listcategories = lista.Select(e => e.Category).ToList(); foreach (var offer in lista) { var offerget = soffer.GetById(offer.Id); if (offerget != null) { offer.OfferPhases = offerget.OfferPhases.Select(e => new Persistence.Entities.OfferPhases().InjectFrom(e)).Cast <Persistence.Entities.OfferPhases>().ToList(); } listoffers.FirstOrDefault(e => e.Id == offer.Id).OfferPhases = offer.OfferPhases.Where(e => e.IdOffer == offer.Id).ToList().Select(t => new OfferPhase().InjectFrom(t)).Cast <OfferPhase>().ToList(); //new OfferPhase().InjectFrom(e)).Cast<OfferPhase>().ToList(); //foreach(var of in offer.OfferPhases.Where(e => e.IdOffer == offer.Id).ToList()) // { // Models.OfferPhase newof = new Models.OfferPhase(); // newof.InjectFrom(of); // listoffers.FirstOrDefault(e => e.Id == offer.Id).OfferPhases.Add(newof); // } if (listoffers.FirstOrDefault(e => e.Id == offer.Id) != null) { listoffers.FirstOrDefault(e => e.Id == offer.Id).Category = new Models.Category();//.InjectFrom(offer.Category); } listoffers.FirstOrDefault(e => e.Id == offer.Id).Category.InjectFrom(offer.Category); listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCity = ((RegisterBindingModel)SessionBag.Current.User).City; listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCountry = ((RegisterBindingModel)SessionBag.Current.User).Country; listoffers.FirstOrDefault(e => e.Id == offer.Id).NameContractor = ((RegisterBindingModel)SessionBag.Current.User).FirstMiddleName; listoffers.FirstOrDefault(e => e.Id == offer.Id).NoPostulados = soffer.GetNoPostuladosByOffer(offer.Id); var dateoferfase1 = soffer.GetPhaseInitial(offer.Id); if (dateoferfase1 == null) { listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = DateTime.Parse("01/01/1900"); } else { ViewBag.InicioEst = dateoferfase1.InitPhase; if (offer.OfferPhases.Count > 0) { var finest = offer.OfferPhases.LastOrDefault(e => e.FinishPhase != null).FinishPhase; ViewBag.FinEst = finest; listoffers.FirstOrDefault(e => e.Id == offer.Id).FinEst = finest; } else { ViewBag.FinEst = dateoferfase1.FinishPhase; listoffers.FirstOrDefault(e => e.Id == offer.Id).FinEst = dateoferfase1.FinishPhase; } listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = dateoferfase1.InitPhase; listoffers.FirstOrDefault(e => e.Id == offer.Id).InicioEst = dateoferfase1.InitPhase; } } if (!regbm.Freelance) { return(View("DetailsForEmployer", listoffers)); } else { return(View("DetailsForFreelance", listoffers)); } }
// GET: Offer public ActionResult Index(string id) { try { SOffer soffer = new SOffer(); int pagenumber = 1; //int.Parse( Request.QueryString.Get("pagenumber")); int itemsperpage = 50; // int.Parse(Request.QueryString.Get("itemsperpage")); string conditions = ""; ///user session bag ZonaFl.Persistence.Entities.AspNetUsers useru = null; ZonaFl.Business.SubSystems.SUser usern = new Business.SubSystems.SUser(); useru = usern.GetUserById(new Guid(id)); if (SessionBag.Current.User == null) { SessionBag.Current.User = useru; } if (!useru.Freelance) { conditions = " where iduser='******'and(O.Status=0 )"; //Request.QueryString.Get("conditions"); } else { conditions = " where OP.StatusPhase<>2 and OP.StatusPhase<>3 and OP.StatusPhase<>4 AND O.Id NOT IN(SELECT Project.idoffer from project)"; //Request.QueryString.Get("conditions"); } var skills = useru.Skills.Where(e => e.CategoryId != null).ToList(); var categories = skills.GroupBy(n => n.CategoryId).ToList(); int i = 0; foreach (var cat in categories) { if (i == 0) { conditions += " and (O.CategoryId=" + cat.Key; } else { conditions += " or O.CategoryId=" + cat.Key; } i += 1; } conditions += ")"; RegisterBindingModel regbm = new RegisterBindingModel(); regbm.InjectFrom(useru); regbm.Skills = useru.Skills.Select(e => new ZonaFl.Models.Skill().InjectFrom(e)).Cast <ZonaFl.Models.Skill>().ToList(); SessionBag.Current.User = regbm; ViewBag.IdUser = id; ViewBag.User = useru.UserName; ViewBag.ImageUser = SessionBag.Current.User.Image; ///// string order = Request.QueryString.Get("order"); SCategory scat = new SCategory(); List <ZonaFl.Persistence.Entities.Category> listcat = scat.FindAll(); ViewBag.Categories = listcat; List <Persistence.Entities.Offer> lista = soffer.GetListPaged(pagenumber, itemsperpage, conditions, order); List <Models.Offer> listoffers = lista.Select(e => new Models.Offer().InjectFrom(e)).Cast <Models.Offer>().ToList(); List <Persistence.Entities.Category> listcategories = lista.Select(e => e.Category).ToList(); Dictionary <int, string> dicofferexiste = new Dictionary <int, string>(); int offeruserexist = -1; if (TempData["OfferMessage"] != null) { dicofferexiste = (Dictionary <int, string>)TempData["OfferMessage"]; offeruserexist = dicofferexiste.FirstOrDefault().Key; } foreach (var offer in lista) { var offerget = soffer.GetById(offer.Id); if (offerget != null) { offer.OfferPhases = offerget.OfferPhases.Select(e => new OfferPhases().InjectFrom(e)).Cast <OfferPhases>().ToList(); } listoffers.FirstOrDefault(e => e.Id == offer.Id).OfferPhases = offer.OfferPhases.Select(e => new OfferPhase().InjectFrom(e)).Cast <OfferPhase>().ToList(); if (listoffers.FirstOrDefault(e => e.Id == offer.Id) != null) { listoffers.FirstOrDefault(e => e.Id == offer.Id).Category = new Models.Category();//.InjectFrom(offer.Category); } listoffers.FirstOrDefault(e => e.Id == offer.Id).Category.InjectFrom(offer.Category); listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCity = ((RegisterBindingModel)SessionBag.Current.User).City; listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCountry = ((RegisterBindingModel)SessionBag.Current.User).Country; listoffers.FirstOrDefault(e => e.Id == offer.Id).NameContractor = ((RegisterBindingModel)SessionBag.Current.User).FirstMiddleName; listoffers.FirstOrDefault(e => e.Id == offer.Id).NoPostulados = soffer.GetNoPostuladosByOffer(offer.Id); if (offer.Id == offeruserexist) { listoffers.FirstOrDefault(e => e.Id == offer.Id).Applicada = true; } var dateoferfase1 = soffer.GetPhaseInitial(offer.Id); if (dateoferfase1 == null) { listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = DateTime.Parse("01/01/1900"); } else { listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = dateoferfase1.InitPhase; } } //listoffers.ForEach(e => e.Category.InjectFrom(listcategories.Where(i => i.Id == e.Id).FirstOrDefault())); if (((RegisterBindingModel)SessionBag.Current.User).Freelance) { return(View("DetailsForFreelance", listoffers)); } else { return(RedirectToAction("Index", "Projects", new { id = SessionBag.Current.User.Id })); } } catch (Exception er) { Log4NetLogger logger2 = new Log4NetLogger(); logger2.CurrentUser = SessionBag.Current.User.Id; if (Request != null) { logger2.Error(er, Request.Path, Request.RawUrl); } else { logger2.Error(er); } } return(RedirectToAction("Index", "Home")); }
public ActionResult Filter(string filter) { if (!string.IsNullOrEmpty(filter) && filter.EndsWith("or ")) { filter = " and " + ReplaceLastOccurrence(filter, "or", ""); } if (!string.IsNullOrEmpty(filter) && filter.EndsWith("and ")) { filter = " and " + ReplaceLastOccurrence(filter, "and", ""); } SOffer soffer = new SOffer(); int pagenumber = 1; //int.Parse( Request.QueryString.Get("pagenumber")); int itemsperpage = 50; // int.Parse(Request.QueryString.Get("itemsperpage")); string conditions = ""; ///user session bag ZonaFl.Persistence.Entities.AspNetUsers useru = null; ZonaFl.Business.SubSystems.SUser usern = new Business.SubSystems.SUser(); string id = ((RegisterBindingModel)SessionBag.Current.User).Id; useru = usern.GetUserById(new Guid(id)); if (!useru.Freelance) { conditions = " where iduser='******' " + filter + "' and OP.StatusPhase<>2 and OP.StatusPhase<>3; "; //Request.QueryString.Get("conditions"); } else { conditions = " where OP.StatusPhase<>2 and OP.StatusPhase<>3 AND O.Id NOT IN(SELECT Project.idoffer from project) " + filter; //Request.QueryString.Get("conditions"); } //se quitan los skill porque aqui se puede haber filtrado por skills diferentes //var skills = useru.Skills.Where(e => e.CategoryId != null).ToList(); //var categories = skills.GroupBy(n => n.CategoryId).ToList(); //int i = 0; //foreach (var cat in categories) //{ // if (i == 0) // { // conditions += " and (O.CategoryId=" + cat.Key; // } // else // { // conditions += " or O.CategoryId=" + cat.Key; // } // i += 1; //} //conditions += ")"; RegisterBindingModel regbm = new RegisterBindingModel(); regbm.InjectFrom(useru); regbm.Skills = useru.Skills.Select(e => new ZonaFl.Models.Skill().InjectFrom(e)).Cast <ZonaFl.Models.Skill>().ToList(); //SessionBag.Current.User = regbm; ViewBag.IdUser = id; ///// string order = Request.QueryString.Get("order"); SCategory scat = new SCategory(); List <ZonaFl.Persistence.Entities.Category> listcat = scat.FindAll(); ViewBag.Categories = listcat; List <Persistence.Entities.Offer> lista = soffer.GetListPaged(pagenumber, itemsperpage, conditions, order); List <Models.Offer> listoffers = lista.Select(e => new Models.Offer().InjectFrom(e)).Cast <Models.Offer>().ToList(); List <Persistence.Entities.Category> listcategories = lista.Select(e => e.Category).ToList(); Dictionary <int, string> dicofferexiste = new Dictionary <int, string>(); int offeruserexist = -1; if (TempData["OfferMessage"] != null) { dicofferexiste = (Dictionary <int, string>)TempData["OfferMessage"]; offeruserexist = dicofferexiste.FirstOrDefault().Key; } foreach (var offer in lista) { var offerget = soffer.GetById(offer.Id); if (offerget != null) { offer.OfferPhases = offerget.OfferPhases.Select(e => new OfferPhases().InjectFrom(e)).Cast <OfferPhases>().ToList(); } listoffers.FirstOrDefault(e => e.Id == offer.Id).OfferPhases = offer.OfferPhases.Select(e => new OfferPhase().InjectFrom(e)).Cast <OfferPhase>().ToList(); if (listoffers.FirstOrDefault(e => e.Id == offer.Id) != null) { listoffers.FirstOrDefault(e => e.Id == offer.Id).Category = new Models.Category();//.InjectFrom(offer.Category); } listoffers.FirstOrDefault(e => e.Id == offer.Id).Category.InjectFrom(offer.Category); listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCity = ((RegisterBindingModel)SessionBag.Current.User).City; listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCountry = ((RegisterBindingModel)SessionBag.Current.User).Country; listoffers.FirstOrDefault(e => e.Id == offer.Id).NameContractor = ((RegisterBindingModel)SessionBag.Current.User).FirstMiddleName; if (offer.Id == offeruserexist) { listoffers.FirstOrDefault(e => e.Id == offer.Id).Applicada = true; } var dateoferfase1 = soffer.GetPhaseInitial(offer.Id); if (dateoferfase1 == null) { listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = DateTime.Parse("01/01/1900"); } else { listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = dateoferfase1.InitPhase; } } //listoffers.ForEach(e => e.Category.InjectFrom(listcategories.Where(i => i.Id == e.Id).FirstOrDefault())); if (((RegisterBindingModel)SessionBag.Current.User).Freelance) { return(PartialView("PartialFilterOffer", listoffers)); } else { return(RedirectToAction("Index", "Projects", new { id = SessionBag.Current.User.Id })); } //SOffer soffer = new SOffer(); //int pagenumber = 1;//int.Parse( Request.QueryString.Get("pagenumber")); //int itemsperpage = 50;// int.Parse(Request.QueryString.Get("itemsperpage")); //string conditions = " where iduser='******' " + filter + "; "; //Request.QueryString.Get("conditions"); //string order = Request.QueryString.Get("order"); //SCategory scat = new SCategory(); //List<ZonaFl.Persistence.Entities.Category> listcat = scat.FindAll(); //ViewBag.Categories = listcat; //List<Persistence.Entities.Offer> lista = soffer.GetListPaged(pagenumber, itemsperpage, conditions, order); //List<Models.Offer> listoffers = lista.Select(e => new Models.Offer().InjectFrom(e)).Cast<Models.Offer>().ToList(); //List<Persistence.Entities.Category> listcategories = lista.Select(e => e.Category).ToList(); //foreach (var offer in lista) //{ // if (listoffers.FirstOrDefault(e => e.Id == offer.Id) != null) // listoffers.FirstOrDefault(e => e.Id == offer.Id).Category = new Models.Category();//.InjectFrom(offer.Category); // listoffers.FirstOrDefault(e => e.Id == offer.Id).Category.InjectFrom(offer.Category); // listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCity = ((RegisterBindingModel)SessionBag.Current.User).City; // listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCountry = ((RegisterBindingModel)SessionBag.Current.User).Country; // listoffers.FirstOrDefault(e => e.Id == offer.Id).NameContractor = ((RegisterBindingModel)SessionBag.Current.User).FirstMiddleName; // var phase= soffer.GetPhaseInitial(offer.Id); // if (phase != null) // { // ViewBag.InicioEst = phase.InitPhase; // if(offer.OfferPhases.Count>0) // ViewBag.FinEst = offer.OfferPhases.LastOrDefault(e => e.FinishPhase != null).FinishPhase; // listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = soffer.GetPhaseInitial(offer.Id).InitPhase; // } // else // { // listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = DateTime.Parse("01/01/1900"); // } //} ////listoffers.ForEach(e => e.Category.InjectFrom(listcategories.Where(i => i.Id == e.Id).FirstOrDefault())); //if (((RegisterBindingModel)SessionBag.Current.User).Freelance) //{ // return PartialView("PartialFilterOffer", listoffers); //} //else //{ // return PartialView("PartialFilterOffer", listoffers); //} }
public ResponseBase InsertOrUpdate(CategoryModel model) { using (var db = new IEDEntities()) { try { var result = new ResponseBase(); var flag = false; SCategory category = null; if (CheckMenuName(model.Id, model.Name, model.CompanyId ?? 0, db) != null) { flag = true; result.IsSuccess = false; result.Errors.Add(new Error() { Message = "Tên Nhóm danh mục đã tồn tại. Vui lòng chọn lại tên khác!", MemberName = "Thêm Mới Menu" }); } if (!flag) { if (model.Id == 0) { category = new SCategory(); model.Name = model.Name.Trim(); Parse.CopyObject(model, ref category); if (model.Icon != "0" && model.Icon != null) { category.Icon = model.Icon.Split(',').ToList().First(); } db.SCategories.Add(category); } else { category = db.SCategories.FirstOrDefault(x => x.Id == model.Id && !x.IsDeleted); if (category != null) { category.Name = model.Name.Trim(); category.Position = model.Position; category.Link = model.Link; category.OrderIndex = model.OrderIndex; category.ModuleId = model.ModuleId; if (model.Icon != "0" && model.Icon != null) { category.Icon = model.Icon.Split(',').ToList().FirstOrDefault(); } category.IsViewIcon = model.IsViewIcon; category.Description = model.Description; category.ModuleId = model.ModuleId; category.UpdatedUser = model.UpdatedUser; category.UpdatedDate = model.UpdatedDate; db.Entry <SCategory>(category).State = System.Data.Entity.EntityState.Modified; } else { result.IsSuccess = false; result.Errors.Add(new Error() { MemberName = "Cập Nhật Nhóm Danh Mục", Message = "Nhóm Danh Mục đang thao tác không tồn tại. Vui lòng kiểm tra lại!" }); } } db.SaveChanges(); result.IsSuccess = true; } return(result); } catch (Exception ex) { throw ex; } } }