Ejemplo n.º 1
0
        public void Delete(Franchisee model)
        {
            var sql  = "delete from Franchisee where AutoId=@AutoId";
            var conn = DbConnectionFactory.CreateConnection();

            conn.Execute(sql, model);
        }
Ejemplo n.º 2
0
        public void Update(Franchisee model)
        {
            var sql  = "update Franchisee set Name=@Name,Email=@Email,Weixin=@Weixin,Phone=@Phone,Address=@Address,Remark=@Remark,ApplyTime=@ApplyTime,ProcessTime=@ProcessTime,Status=@Status where AutoId=@AutoId";
            var conn = DbConnectionFactory.CreateConnection();

            conn.Execute(sql, model);
        }
Ejemplo n.º 3
0
        // GET: Store Index - shows inventory for the user's store.
        public async Task <IActionResult> Index(string productName, int threshold, int id = 1)
        {
            FetchStore();
            int storeID = Store.StoreID;

            Franchisee franchisee = new Franchisee(_context, UserID, storeID);

            List <StoreInventory> inventory = await franchisee.GetStoreInventory();

            // Eager loading the Product table - join between StoreInventory and the Product table.

            var productQuery = _context.StoreInventory.Include(x => x.Product).Where(p => p.StoreID == storeID);

            if (!string.IsNullOrWhiteSpace(productName))
            {
                inventory = await franchisee.GetStoreInventory(productName);

                // Storing the search into ViewBag to populate the textbox with the same value for convenience.
                ViewBag.ProductName = productName;
            }

            if (threshold != 0)
            {
                inventory = await franchisee.GetStoreInventoryBelowThreshold(threshold);

                // Storing the search into ViewBag to populate the textbox with the same value for convenience.
                ViewBag.Threshold = threshold;
            }

            //Passing a List<OwnerInventory> model object to the View.

            return(View(inventory));
        }
Ejemplo n.º 4
0
 public CustomerController(MagicMVCContext context, UserManager <ApplicationUser> userManager)
 {
     _context     = context;
     _userManager = userManager;
     customer     = new Customer(_context);
     franchisee   = new Franchisee(_context);
 }
Ejemplo n.º 5
0
 public async Task <FranchiseeDto> AddOrUpdateFranchisee(Franchisee franchisee)
 {
     if (franchisee == null)
     {
         throw new ArgumentNullException(nameof(franchisee));
     }
     ClcWorldContext.Franchisees.AddOrUpdate(franchisee);
     return(await SaveAsync() ? franchisee.ToMap <FranchiseeDto>() : null);
 }
Ejemplo n.º 6
0
        public int Insert(Franchisee model)
        {
            var connection = DbConnectionFactory.CreateConnection();
            var id         = connection.Query <int>(@"Insert into Franchisee(Name,Email,Weixin,Phone,Address,Remark,ApplyTime,ProcessTime,Status)
values (@Name,@Email,@Weixin,@Phone,@Address,@Remark,@ApplyTime,@ProcessTime,@Status);SELECT LAST_INSERT_ID()",
                                                    model).FirstOrDefault();

            return(id);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Franchisee franchisee = await db.Franchisees.FindAsync(id);

            db.Franchisees.Remove(franchisee);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
        public async Task <bool> DeleteFranchiseeById(int id)
        {
            var franchisee = new Franchisee {
                Id = id
            };

            ClcWorldContext.Franchisees.Attach(franchisee);
            ClcWorldContext.Franchisees.Remove(franchisee);
            return(await SaveAsync());
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,date,name,email,contact,login,password,rid,image,Type,status")] Franchisee franchisee)
        {
            if (ModelState.IsValid)
            {
                db.Entry(franchisee).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(franchisee));
        }
Ejemplo n.º 10
0
 public async Task DeleteFranchiseeAsync(Franchisee franchisee)
 {
     try
     {
         dbContext.Franchisees.Remove(franchisee);
         await dbContext.SaveChangesAsync();
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 11
0
 public async Task <Franchisee> AddFranchiseeAsync(Franchisee franchisee)
 {
     try
     {
         dbContext.Franchisees.Add(franchisee);
         await dbContext.SaveChangesAsync();
     }
     catch (Exception)
     {
         throw;
     }
     return(franchisee);
 }
        // GET: Auth/Franchisees/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Franchisee franchisee = await db.Franchisees.FindAsync(id);

            if (franchisee == null)
            {
                return(HttpNotFound());
            }
            return(View(franchisee));
        }
Ejemplo n.º 13
0
        // GET: Unstocked Items - show items in Owner Inventory which Store does not have in stock.
        public async Task <IActionResult> Unstocked()
        {
            FetchStore();
            int        storeID    = Store.StoreID;
            Franchisee franchisee = new Franchisee(_context, UserID, storeID);

            // Load products in OwnerInventory that aren't in this Store's Inventory
            var storeInventory = await franchisee.GetStoreInventory();

            List <OwnerInventory> inventory = await _context.OwnerInventory.Include(i => i.Product).Where(o => !storeInventory.Any(s => s.ProductID == o.ProductID)).ToListAsync();

            //Passing a List<OwnerInventory> model object to the View.

            return(View(inventory));
        }
Ejemplo n.º 14
0
 public async Task <Franchisee> UpdateFranchiseeAsync(Franchisee franchisee)
 {
     try
     {
         var franchiseeExist = dbContext.Franchisees.FirstOrDefault(p => p.Id == franchisee.Id);
         if (franchiseeExist != null)
         {
             dbContext.Update(franchisee);
             await dbContext.SaveChangesAsync();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(franchisee);
 }
Ejemplo n.º 15
0
        public async Task <IdentityResult> CreateAsync(User user, CancellationToken cancellationToken)
        {
            try
            {
                // Insert the user
                await DbContext.AddAsync(user, cancellationToken);

                // Assign the user to it's default role based on it's type
                await AddToRoleAsync(user, user switch
                {
                    Administrator _ => Role.Admin,
                    Customer _ => Role.Customer,
                    Employee _ => Role.Employee,
                    Franchisee _ => Role.Franchisee,
                    _ => throw new ArgumentException($"Unknown user type {user.GetType()}")
                }, cancellationToken);

                await DbContext.SaveChangesAsync(cancellationToken);

                return(IdentityResult.Success);
            }
Ejemplo n.º 16
0
        public async Task CreateNewFranchisee()
        {
            var user = new Franchisee
            {
                FirstName   = Input.FirstName,
                LastName    = Input.LastName,
                Email       = Input.Email,
                PhoneNumber = Input.PhoneNumber,
                Location    = Input.Location
            };
            IdentityResult result = await UserManager.CreateAsync(user, Input.Password);

            if (result.Succeeded)
            {
                Logger.LogInformation("Franchisee created a new account with password.");

                await EmailManager.SendConfirmationEmailAsync(user);
            }

            await BlazoredModal.Close(ModalResult.Ok(true));
        }
Ejemplo n.º 17
0
        public ActionResult MyCompanyContact(int FranchiseeId)
        {
            var listEClass = new List <Franchisee>();
            var eclass     = new Franchisee();

            var cDetails = (from p in DB.tbl_Franchise_Contacts where p.FranchiseID == FranchiseeId select p);


            foreach (var details in cDetails)
            {
                var det   = details;
                var phone = (from d in DB.tbl_PhoneType where d.PhoneTypeID == det.PhoneTypeID select d).FirstOrDefault();
                if (phone != null)
                {
                    eclass.FranchiseID        = details.FranchiseID;
                    eclass.PhoneType          = phone.PhoneType;
                    eclass.PhoneNumber        = details.PhoneNumber;
                    eclass.PhoneTypeID        = details.PhoneTypeID;
                    eclass.ContactName        = details.ContactName;
                    eclass.FranchiseContactID = details.FranchiseContactID;

                    var summary = new Franchisee
                    {
                        FranchiseContactID = eclass.FranchiseContactID,
                        PhoneTypeID        = eclass.PhoneTypeID,
                        FranchiseID        = eclass.FranchiseID,
                        PhoneNumber        = eclass.PhoneNumber,
                        PhoneType          = eclass.PhoneType,
                        ContactName        = eclass.ContactName
                    };
                    listEClass.Add(summary);
                }
            }

            return(Json(listEClass));
        }
Ejemplo n.º 18
0
 public void UpdateFranchisee(Franchisee model)
 {
     franchiseeRepository.Update(model);
 }
Ejemplo n.º 19
0
 public void DeleteFranchisee(Franchisee model)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 20
0
 public int AddFranchisee(Franchisee model)
 {
     return(franchiseeRepository.Insert(model));
 }
 public Franchisee_StockRequestsController(MagicMVCContext context, UserManager <ApplicationUser> userManager)
 {
     _context     = context;
     franchisee   = new Franchisee(_context);
     _userManager = userManager;
 }