public IActionResult Index(CompanyModel company) { var model = new CompanyAddViewModel() { NumberOfCharsInName = company.Name.Length, NumberOfCharsInDescription = company.Description.Length, isHidden = !company.isVisible }; var item = new ItemEntity() { Id = Guid.NewGuid().ToString(), Name = company.Name, Description = company.Description, isVisible = company.isVisible }; _dbContext.Items.Add(item); _dbContext.SaveChanges(); model.Items = _dbContext.Items.ToList(); return(View("Company Added", model)); }
public ActionResult Add() { var model = new CompanyAddViewModel { Company = new Company(), }; return(View(model)); }
public virtual ActionResult CreateCompany(CompanyAddViewModel model) { //1048576 Bytes == 1024 * 1024 KB == 1 MB ---> 1024 if (ModelState.IsValid) { try { if (model.Image != null) { if (model.Image.ContentLength > 0) { using (var img = Image.FromStream(model.Image.InputStream)) { string fileName = TODO.CheckExistFile(Server.MapPath("~/Content/Images/Company/"), model.Image.FileName); TODO.UploadImage(img, new Size(70, 70), Server.MapPath("~/Content/Images/Company/"), fileName); model.ImageLogo = fileName; } } } model.Title = HelperTitle.GetTitle(Address: model.Address); var company = new Company { Address = model.Address, ImageLogo = model.ImageLogo, Explain = model.Explain, Name = model.Name, Title = model.Title }; _companyService.Create(company); if (_unitOfWork.SaveAllChanges() > 0) { return(RedirectToAction(MVC.admin.Company.ActionNames.DetailsCompany, new { Id = company.Id })); } else { TempData["createCompany"] = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning }); return(View()); } } catch { TempData["createCompany"] = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning }); return(View()); } } else { return(View()); } }
public ActionResult Add(Company company) { if (ModelState.IsValid) { _companyService.Add(company); TempData["addjobmessage"] = "Job has been added sucessfully"; return(RedirectToAction("Add", "Job", new { area = "Admin" })); } CompanyAddViewModel model = new CompanyAddViewModel() { Company = company, }; return(View(model)); }
public async Task <ActionResult> Add(CompanyAddViewModel data) { if (ModelState.IsValid) { try { data.active = true; data.createdBy = Session["user_id"].ToString(); data.createdDatetime = DateTime.Now; var postTask = await client.PostAsJsonAsync("/api/Company/Add", data); if (postTask.IsSuccessStatusCode) { return(RedirectToAction("Index", "Company")); } } catch (Exception e) { ViewBag.Error = e.Message; return(View("Index", ViewBag.Error)); } } return(RedirectToActionPermanent("Index")); }
public ActionResult Add() { CompanyAddViewModel model = new CompanyAddViewModel(); return(View("Add", model)); }
public async Task <JsonResult> CheckCompanyIfExist(CompanyAddViewModel data) { return(await checkCompany(data.comp_id) ? Json(true, JsonRequestBehavior.AllowGet) : Json(false, JsonRequestBehavior.AllowGet)); }