public JsonResult SavePayment(Payment payment) { if (payment.PaymentKey == 0) { obj.Payments.Add(payment); obj.SaveChanges(); } else { var paymentObj = obj.Payments.SingleOrDefault(x => x.PaymentKey == payment.PaymentKey); if (paymentObj != null) { paymentObj.PaymentDate = payment.PaymentDate; paymentObj.PaymentCheckNumber = payment.PaymentCheckNumber; paymentObj.PaymentTypeKey = payment.PaymentTypeKey; paymentObj.PaymentTo = payment.PaymentTo; paymentObj.PaymentVendorInvoiceNumber = payment.PaymentVendorInvoiceNumber; paymentObj.PaymentNote = payment.PaymentNote; obj.SaveChanges(); } } return(Json(payment, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> CreateEdit(Roles model) { string returnId = ""; try { if (model.Id != null) { var user = oDB.AspNetRoles.Where(m => m.Id == model.Id).FirstOrDefault(); user.Name = model.Name; oDB.Entry(user).State = System.Data.Entity.EntityState.Modified; oDB.SaveChanges(); returnId = model.Id; } else { Guid IdGen = Guid.NewGuid(); var user = new WebApplication1.Models.AspNetRole { Id = IdGen.ToString(), Name = model.Name, }; oDB.AspNetRoles.Add(user); oDB.SaveChanges(); } return(Json(new { returnId = returnId, }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { } ViewBag.Action = (model.Id != null) ? "Edit" : "Create"; return(Json(new { returnId = returnId, }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveUpdatePerson(Person person) { var personObj = obj.People.SingleOrDefault(x => x.PersonKey == person.PersonKey); if (personObj != null) { personObj.PersonName = person.PersonName; personObj.PersonAddress = person.PersonAddress; personObj.PersonCity = person.PersonCity; personObj.PersonStateKey = person.PersonStateKey; personObj.PersonZipCode = person.PersonZipCode; personObj.PersonNote = person.PersonNote; personObj.VendorFederalEIN = person.VendorFederalEIN; personObj.VendorDefaultTerms = person.VendorDefaultTerms; obj.SaveChanges(); } return(Json(person, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveUpdateProgram(Program program) { if (program.ProgramKey == 0) { obj.Programs.Add(program); obj.SaveChanges(); } else { var programObj = obj.Programs.SingleOrDefault(x => x.ProgramKey == program.ProgramKey); if (programObj != null) { programObj.ProgramKey = program.ProgramKey; programObj.ProgramName = program.ProgramName; programObj.ProgramNote = program.ProgramNote; obj.SaveChanges(); } } return(Json(program, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveUpdateAccount(Account account) { if (account.AccountKey == 0) { obj.Accounts.Add(account); obj.SaveChanges(); } else { var accountObj = obj.Accounts.SingleOrDefault(x => x.AccountKey == account.AccountKey); if (accountObj != null) { accountObj.AccountKey = account.AccountKey; accountObj.AccountName = account.AccountName; accountObj.GLAccountCode = account.GLAccountCode; accountObj.AccountTypeKey = account.AccountTypeKey; accountObj.AccountParentKey = account.AccountParentKey; accountObj.AccountNote = account.AccountNote; obj.SaveChanges(); } } return(Json(account, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveUpdateBudget(Budget budget) { if (budget.BudgetKey == 0) { obj.Budgets.Add(budget); obj.SaveChanges(); } else { var budegtObj = obj.Budgets.SingleOrDefault(x => x.BudgetKey == budget.BudgetKey); if (budegtObj != null) { budegtObj.BudgetProgramKey = budget.BudgetProgramKey; budegtObj.BudgetTermKey = budget.BudgetTermKey; budegtObj.BudgetAccountKey = budget.BudgetAccountKey; budegtObj.BudgetAmount = budget.BudgetAmount; budegtObj.BudgetNote = budget.BudgetNote; obj.SaveChanges(); } } return(Json(budget, JsonRequestBehavior.AllowGet)); }
public ActionResult Delete(string id) { NYFSEntities2 _entities = new NYFSEntities2(); try { var q = _entities.AspNetUsers.Where(m => m.Id == id).SingleOrDefault(); _entities.AspNetUsers.Remove(q); _entities.SaveChanges(); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception) { } return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> CreateEdit(Users model) { // RequestResultModel requestModel = new RequestResultModel(); string returnId = ""; try { model.CreatedDate = DateTime.UtcNow; model.ModifiedDate = DateTime.UtcNow; if (model.Ids != null) { ViewBag.LoadRoles = (new UserDB()).LoadRoles(); var user = oDB.AspNetUsers.Where(m => m.Id == model.Ids).FirstOrDefault(); user.Name = model.Name; user.UserName = model.UserName; user.CompanyEmail = model.CompanyEmail; user.Address = model.Address; user.City = model.City; user.Zip = model.Zip; user.PhoneNumber = model.Contact; user.Notes = model.Notes; user.isActive = true; oDB.Entry(user).State = System.Data.Entity.EntityState.Modified; oDB.SaveChanges(); returnId = model.Ids; } else { ViewBag.LoadRoles = (new UserDB()).LoadRoles(); var user = new ApplicationUser { UserName = model.UserName, Email = model.Email, Name = model.Name, CompanyEmail = model.Email, Address = model.Address, City = model.City, CreatedDate = model.CreatedDate.Value, Zip = model.Zip, PhoneNumber = model.Contact, Notes = model.Notes, isActive = true, }; var result = UserManager.Create(user, model.Password); if (result.Succeeded) { var currentUser = UserManager.FindByName(user.UserName); var roleresult = UserManager.AddToRole(currentUser.Id, model.RoleName); // returnId = currentUser.Id; // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 } // oDB.tblUsers.Add(user); // oDB.SaveChanges(); } return(Json(new { returnId = returnId, }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { } ViewBag.Action = (model.Id > 0) ? "Edit" : "Create"; return(Json(new { returnId = returnId, }, JsonRequestBehavior.AllowGet)); }