private void AddWarehouse(M model) { var db = Request.GetOwinContext().Get <BusinessDbContext>(); var shopId = model.Id; BusinessSeedData.AddWarehouse(db, shopId); }
private void AddSupplier(M model) { var db = Request.GetOwinContext().Get <BusinessDbContext>(); var shopId = model.Id; BusinessSeedData.AddSupplier(shopId, db, model.Name); }
private void AddUser(M model) { var userManager = Request.GetOwinContext().Get <ApplicationUserManager>(); var shopName = Regex.Replace(model.Name.ToLower(), "[^a-zA-Z0-9]", string.Empty); string userName = "******" + shopName + "." + "bizbook365.com"; var user = new ApplicationUser { UserName = userName, Email = userName, IsActive = true, EmailConfirmed = true, PhoneNumber = model.Phone, ShopId = model.Id, FirstName = "Admin", LastName = model.Name }; IdentityResult result = userManager.Create(user, "Pass@" + model.Phone); if (result.Succeeded) { var addedToRole = userManager.AddToRole(user.Id, ApplicationRoles.ShopAdmin.ToString()); if (addedToRole.Succeeded) { user.RoleName = ApplicationRoles.ShopAdmin.ToString(); userManager.Update(user); } } }
private void AddAccountHeads(M model) { var db = Request.GetOwinContext().Get <BusinessDbContext>(); var shopId = model.Id; BusinessSeedData.AddAccountHeads(db, shopId); BusinessSeedData.AddWallet(db, shopId); }
public IHttpActionResult Delete(string id) { try { M shop = Service.GetById(id); shop.IsActive = false; shop.IsDeleted = true; shop.ExpiryDate = DateTime.Now; bool delete = Service.Edit(shop); Logger.Debug("Deleted entity {TypeName} with value {id}", typeName, id); return(Ok(delete)); } catch (Exception exception) { Logger.Fatal(exception, "Exception occurred while saving {TypeName}", typeName); return(InternalServerError(exception)); } }
public IHttpActionResult Put(M model) { M shop = Service.GetById(model.Id); shop.Modified = model.Modified; shop.ModifiedBy = model.ModifiedBy; if (model.ExpiryDate != DateTime.MinValue && model.ExpiryDate != DateTime.MaxValue) { shop.ExpiryDate = model.ExpiryDate; } shop.Name = model.Name; shop.WcUrl = model.WcUrl; shop.WcKey = model.WcKey; shop.WcSecret = model.WcSecret; shop.WcWebhookSource = model.WcWebhookSource; shop.WcVersion = model.WcVersion; bool edit = Service.Edit(shop); return(Ok(edit)); }
public IHttpActionResult Add(M model) { using (var scope = new TransactionScope(TransactionScopeOption.Required)) { model.RegistrationDate = DateTime.UtcNow; model.IsActive = true; model.IsDeleted = false; model.IsVerified = true; bool post = Service.Add(model); if (!string.IsNullOrWhiteSpace(post.ToString())) { AddUser(model); AddAccountHeads(model); AddBrand(model); AddSupplier(model); AddProduct(model); AddWarehouse(model); } scope.Complete(); return(Ok()); } }