public ActionResult Create([Bind(Include = "Id,Name,ShortName,Location,Description")] Organization organization) { if (ModelState.IsValid) { bool isName = _organizationManager.IsOrganizationNameExist(organization.Name); bool isShortName = _organizationManager.IsShortNameExist(organization.ShortName); if (isName) { ViewBag.NameCssClass = "Alert Alert-warning"; ViewBag.NameMessageType = "Warning"; ViewBag.Message = "This orgaization name already exist!"; } else if (isShortName) { ViewBag.ShortNameCssClass = "Alert Alert-warning"; ViewBag.ShortNameMessageType = "Warning"; ViewBag.ShortNameMessage = "This organization short-name already exist!"; } else { _organizationManager.Add(organization); return(RedirectToAction("Index")); } } return(View(organization)); }
public ActionResult Save(Organization organization) { List <Organization> organizations = manager.GetAll(); ViewBag.organizationList = organizations.ToList(); bool IsCodeExit = manager.IsCodeExist(organization.Code); if (IsCodeExit) { ViewBag.message = "Code is already exist"; } else { bool Save = manager.Add(organization); if (Save) { ViewBag.message = "Saved Successfull"; } else { ViewBag.message = "Saved Failed"; } } return(View()); }
public ActionResult Add(OrganizationVM organizationVm) { if (organizationVm.ImageFile != null) { string fileName = Path.GetFileNameWithoutExtension(organizationVm.ImageFile.FileName); string extension = Path.GetExtension(organizationVm.ImageFile.FileName); organizationVm.ImagePath = fileName + extension; fileName = Path.Combine(Server.MapPath("~/images/"), organizationVm.ImagePath); organizationVm.ImageFile.SaveAs(fileName); } Organization organization = Mapper.Map <Organization>(organizationVm); if (ModelState.IsValid) { try { if (_organizationManager.Add(organization)) { TempData["success"] = "Add successfully!"; return(RedirectToAction("Add")); } } catch (Exception e) { TempData["exception"] = "Failed to add!" + e.Message; } } OrganizationVM org = new OrganizationVM() { Organizations = _organizationManager.GetAll() }; return(View(org)); }
public ActionResult Entry(Organization organization) { if (ModelState.IsValid) { _organizationManager.Add(organization); } return(View()); }
public ActionResult Entry(Organization organization) { //if (!string.IsNullOrEmpty(organization.Name) && organization.ContactNo > 0) if (ModelState.IsValid) { _organizationManager.Add(organization); } return(View()); }
//[ValidateAntiForgeryToken] public ActionResult Add(OrganizationViewModel organizationViewModel) { OrganizationManager organizationManager = new OrganizationManager(); Organization ParentOrganization = new Organization(); Organization newOrganization = new Organization(); ParentOrganization = organizationManager.Read(x => x.Id == organizationViewModel.ParentOrganizationGUID).First(); newOrganization.Name = organizationViewModel.Name; newOrganization.ParentOrganization = ParentOrganization; organizationManager.Add(newOrganization); organizationManager.saveChanges(); return(RedirectToAction("Index")); }
public ActionResult Entry(OrganizationEntryVm model) { if (ModelState.IsValid) { var organization = Mapper.Map <Organization>(model); bool isAdded = _organizationManager.Add(organization); if (isAdded) { return(RedirectToAction("Index")); } } return(View()); }
public ApiResult <bool> AddOrg(OrgModel org) { ApiResult <bool> apiResult = new ApiResult <bool>(); OrgModel orgnization = org; if (org.organization.isroot) { org.parentOrgId = "-1"; } bool res = orgManager.Add(orgnization); apiResult.Code = res?ApiResultStatu.OK: ApiResultStatu.Error; apiResult.Success = res; apiResult.Data = res; return(apiResult); }
public ActionResult Entry(Organization organization) { bool isSaved = organizationManager.Add(organization); if (isSaved) { ViewBag.SuccessMessage = "Saved Successfully!"; } else { ViewBag.ErrorMessage = "Save Failed!"; } return(View()); }
public ActionResult Save(OrganizationViewModel organizationVm) { ModelState.Remove("Id"); if (ModelState.IsValid) { if (organizationVm.Id == 0) { bool isShortNameExist = _organizationManager.IsShortNameExist(organizationVm.ShortName); if (isShortNameExist) { ViewBag.Message = "This Organization Short Name already Exist"; return(View("OrganizationForm")); } var organization = new Organization() { Name = organizationVm.Name, ShortName = organizationVm.ShortName, Location = organizationVm.Location, Description = organizationVm.Description }; _organizationManager.Add(organization); ModelState.Clear(); return(View("OrganizationForm")); } var organizationInDb = _organizationManager.SingleOrganization(organizationVm.Id); if (organizationInDb == null) { return(HttpNotFound()); } organizationInDb.Name = organizationVm.Name; organizationInDb.ShortName = organizationVm.ShortName; organizationInDb.Description = organizationVm.Description; organizationInDb.Location = organizationVm.Location; _organizationManager.Update(organizationInDb); ModelState.Clear(); return(View("OrgList")); } return(View("OrganizationForm", organizationVm)); }
public static void init() { Organization org = new Organization(); org.id = "od9a2123-2151-43cf-b8f0-384dbf763740"; org.createrTime = System.DateTime.Now; org.creater = "ad9a2123-2151-43cf-b8f0-384dbf763741"; org.orgCode = "MyCompany"; org.orgName = "我的公司"; org.isroot = true; //初始化表 manager.InitTable(); Organization vorg = manager.Get(org.id);//验证当前user是否已经存在 //不存在就初始化当前数据 if (vorg == null || string.IsNullOrEmpty(vorg.id)) { //插入数据 manager.Add(org); } }
public string Add(OrganizationCreateVM orgVm) { if (ModelState.IsValid) { var organization = Mapper.Map <Organization>(orgVm); bool isAdded = _organizationManager.Add(organization); if (isAdded) { return("Successfully Saved!"); } else { return("Sorry Execution Failed"); } } return("Error Occured"); }
public ActionResult Entry(OrganizationCreateVm entity) { HttpPostedFileBase file = Request.Files["uploadImage"]; if (file != null) { entity.Logo = ConvertToBytes(file); if (ModelState.IsValid) { var organization = Mapper.Map <Organization>(entity); var organizations = _organizationManager.GetAllOrganization(); if (organizations.FirstOrDefault(x => x.Code == organization.Code) != null) { ViewBag.Message = "Exist"; return(View(entity)); } else { bool isAdded = _organizationManager.Add(organization); if (isAdded) { ModelState.Clear(); ViewBag.Message = "Saved";; return(View()); } } } else { ViewBag.Message = "Failed"; return(View(entity)); } } ModelState.AddModelError("", "An Unknown Error Occured!"); return(View(entity)); }