/// <summary> /// Deprecated Method for adding a new object to the TblCompanies EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTblCompanies(TblCompany tblCompany) { base.AddObject("TblCompanies", tblCompany); }
/// <summary> /// Create a new TblCompany object. /// </summary> /// <param name="companyId">Initial value of the CompanyId property.</param> /// <param name="companyName">Initial value of the CompanyName property.</param> public static TblCompany CreateTblCompany(global::System.Int32 companyId, global::System.String companyName) { TblCompany tblCompany = new TblCompany(); tblCompany.CompanyId = companyId; tblCompany.CompanyName = companyName; return tblCompany; }
public ActionResult Save(CompanyViewModel companyViewModel) { try { if (ModelState.IsValid) { //add if (companyViewModel.CompanyId == 0 && companyViewModel.ActionName == "Add") { var model = new TblCompany() { CompanyId = companyViewModel.CompanyId + 1, CompanyName = companyViewModel.CompanyName, Address = companyViewModel.Address, CreatedBy = "Rasel", CreatedDate = DateTime.Now, UpdatedBy = "Rasel", UpdatedDate = DateTime.Now }; _companyRepository.Insert(model); } else if (companyViewModel.ActionName == "Edit") //edit { TblCompany company = _companyRepository.GetById(Convert.ToInt32(companyViewModel.CompanyId)); if (company != null) { company.CompanyId = companyViewModel.CompanyId; company.CompanyName = companyViewModel.CompanyName; company.Address = companyViewModel.Address; company.UpdatedBy = "Rasel"; company.UpdatedDate = DateTime.Now; _companyRepository.Update(company); } else { return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, companyViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject())); } } _companyRepository.Save(); return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, companyViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully.")); } return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, companyViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState))); } catch (Exception ex) { return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, companyViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageFormat(ex))); } }