public ActionResult Create([Bind(Include = "Id,Name,Description,ChannelId,StartTime,EndTime")] Shift shift) { if (ModelState.IsValid) { shift.CreatedBy = User.Identity.GetUserId <int>(); shift.IsDeleted = false; shift.Status = true; db.Shifts.Add(shift); db.SaveChanges(); Session["success"] = "The Shift has been created"; return(RedirectToAction("Index")); } ViewBag.ChannelId = new SelectList(db.Channels, "Id", "ChannelName", shift.ChannelId); return(View(shift)); }
public ActionResult Create([Bind(Include = "Id,TaxName,CategoryId,CategoryDescription,TaxRateId,CustCatId")] Tax tax) { if (ModelState.IsValid) { tax.CreatedBy = User.Identity.GetUserId <int>(); // tax.CreatedAt = DateTime.Now; tax.IsDeleted = false; tax.IsActive = true; db.Taxes.Add(tax); db.SaveChanges(); Session["success"] = "Tax Created"; return(RedirectToAction("Index")); } ViewBag.CustCatId = new SelectList(db.CustomerTaxCategories, "Id", "CustCatName", tax.CustCatId); ViewBag.CategoryId = new SelectList(db.TaxCategories, "Id", "CategoryName", tax.CategoryId); ViewBag.TaxRateId = new SelectList(db.TaxRates, "Id", "TaxRateName", tax.TaxRateId); return(View(tax)); }
public ActionResult Create([Bind(Include = "Id,ChannelName,ChannelDescription,ChannelType,Country,Address,City")] Channels channels) { if (ModelState.IsValid) { channels.CreatedAt = DateTime.Now; channels.CreatedBy = User.Identity.GetUserId <int>(); channels.IsDeleted = false; db.Channels.Add(channels); db.UserAllocatedChannels.Add( new UserAllocatedChannels() { ChannelId = channels.Id, UserId = Library.UserId }); db.SaveChanges(); Session["success"] = "Channel Created"; return(RedirectToAction("Index")); } ViewBag.ChannelType = new SelectList(db.ChannelTypes, "Id", "Type", channels.ChannelType); return(View(channels)); }
public ActionResult Create([Bind(Include = "Id,WarehouseName,WarehouseLocation,WarehouseType,MaximumCapacity")] Warehouse warehouse) { if (ModelState.IsValid) { warehouse.CreatedAt = DateTime.Now; db.Warehouses.Add(warehouse); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.WarehouseType = new SelectList(db.WarehouseTypes, "Id", "Type", warehouse.WarehouseType); return(View(warehouse)); }
public void AssignRole(long roleId, long menuId, long parentId, string cruds) { var context = new IMSDataEntities(); var count = context.UserRoleAllocations.Where(x => x.RoleId == roleId && x.MenuId == menuId); if (!count.Any()) { context.UserRoleAllocations.Add( new UserRoleAllocation { MenuId = menuId, RoleId = roleId, ParentId = parentId, CrudActions = cruds } ); context.SaveChanges(); } }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Email,PIN,IdNumber,Password,PhoneNumber,ChannelId,Role,BusinessRole")] Staff staff) { var userId = 0; if (ModelState.IsValid) { // //here create a user account if it is specfied if (Request.Form["UserAccont"] == "1") { var user = new ApplicationUser { Channel = staff.ChannelId, UserName = staff.Name, Email = staff.Email, PhoneNumber = staff.PhoneNumber.ToString(), CreatedBy = Library.UserId }; Debug.WriteLine("reached here"); // var userMan = new UserManager<ApplicationUserManager,string>(); var result = await UserManager.CreateAsync(user, "123456"); if (result.Succeeded) { userId = user.Id; // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); //if the account has been created assign the user to the role assigned var userRole = db.UserRoles.Add(new UserRoles() { RoleId = staff.Role, UserId = user.Id }); Debug.WriteLine("saving"); // db.SaveChanges(); // await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // return RedirectToAction("Index", "Staffs"); } } staff.CreatedAt = DateTime.Now; staff.CreatedBy = User.Identity.GetUserId <int>(); staff.IsActive = true; staff.IsDeleted = false; staff.UserId = userId; db.Staffs.Add(staff); db.SaveChanges(); Session["success"] = "Staff created"; return(RedirectToAction("Index")); } ViewBag.BusinessRole = new SelectList(db.BusinessRoles, "Id", "Name", staff.BusinessRole); ViewBag.ChannelId = new SelectList(db.Channels, "Id", "ChannelName", staff.ChannelId); ViewBag.Role = new SelectList(db.Roles, "RoleId", "RoleName", staff.Role); return(View(staff)); }
public ActionResult Create([Bind(Include = "Id,Name,PostalAddress,PostalCode,City,Contact1,Contact2,Email,PinNumber,ContactPersonName,CreditLimit")] Supplier supplier) { if (ModelState.IsValid) { db.Supppliers.Add(supplier); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(supplier)); }