Beispiel #1
0
        public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await _userManager.CreateAsync(user, model.Password);

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

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
                    await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl);

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    await _userManager.AddToRoleAsync(user, model.RoleName);

                    _logger.LogInformation("User created a new account with password.");


                    #region set table connection
                    //connect with our own user table here.
                    Login lg = _context.Login.Where(p => p.Email == model.Email).FirstOrDefault();
                    if (lg == null)
                    {
                        lg          = new Login();
                        lg.Email    = model.Email;
                        lg.Password = "******";
                        _context.Add(lg);
                        _context.SaveChanges();

                        MyUser u = new MyUser();
                        u.Name   = model.Name;
                        u.DeptId = _context.Department.Where(p => p.Name == model.Department).FirstOrDefault().DeptId;
                        u.RoleId = _context.Role.Where(p => p.Name == model.RoleName).FirstOrDefault().RoleId;

                        u.Email = model.Email;
                        _context.Add(u);
                        _context.SaveChanges();
                    }


                    #endregion

                    return(RedirectToLocal(returnUrl));
                }
                AddErrors(result);
            }

            return(View(model));
        }
Beispiel #2
0
        public Retrieval GenRetrievalAndReturn(Retrieval r1)
        {
            dbcontext.Retrievals.Add(r1);
            dbcontext.SaveChanges();

            Retrieval r = dbcontext.Retrievals.Include(m => m.Clerk).FirstOrDefault(x => x.Id == r1.Id);

            return(r);
        }
Beispiel #3
0
        public PurchaseOrder Create(PurchaseOrder po)
        {
            dbcontext.PurchaseOrders.Add(po);
            dbcontext.SaveChanges();
            int id = po.Id;

            PurchaseOrder newpo = dbcontext.PurchaseOrders.FirstOrDefault(m => m.Id == id);

            return(newpo);
        }
Beispiel #4
0
        public void DeleteAdvDetails(AdjustmentVoucherDetail avd)
        {
            AdjustmentVoucherDetail original = dbcontext.AdjustmentVoucherDetails.FirstOrDefault(m => m.Id == avd.Id);

            if (original != null)
            {
                dbcontext.AdjustmentVoucherDetails.Remove(original);
            }
            dbcontext.SaveChanges();
        }
        public bool UpdatePurchaseOrderDetail(PurchaseOrderDetail pod)
        {
            var original = dbcontext.PurchaseOrderDetails.Find(pod.Id);

            if (original == null)
            {
                throw new Exception();
            }
            original.QtyReceived        = pod.QtyReceived;
            original.ReceivedByClerkId  = pod.ReceivedByClerkId;
            original.ReceivedDate       = pod.ReceivedDate;
            original.SupplierDeliveryNo = pod.SupplierDeliveryNo;
            original.Remark             = pod.Remark;
            original.Status             = pod.Status;

            dbcontext.SaveChanges();
            return(true);
        }
Beispiel #6
0
 public bool UpdateCollectionPoint(string deptid, int collectionpointId)
 {
     try
     {
         var original = dbcontext.Departments.Find(deptid);
         if (original == null)
         {
             throw new Exception();
         }
         original.CollectionPointId = collectionpointId;
         dbcontext.SaveChanges();
         return(true);
     }
     catch
     {
         throw new Exception("Error updating collection point");
     }
 }
 public RequisitionDetail UpdateRetrievalId(RequisitionDetail rd)
 {
     dbcontext.RequisitionDetails.Update(rd);
     dbcontext.SaveChanges();
     return(dbcontext.RequisitionDetails.Include(m => m.Requisition)
            .Include(m => m.Product)
            .Include(m => m.Retrieval)
            .Include(m => m.Retrieval).FirstOrDefault(x => x.Id == rd.Id));
 }
Beispiel #8
0
 public Employee AssignDelegateDate(Employee emp)
 {
     try
     {
         Employee original = dbcontext.Employees.FirstOrDefault(m => m.Id == emp.Id);
         if (original != null)
         {
             original.DelegateFromDate = emp.DelegateFromDate;
             original.DelegateToDate   = emp.DelegateToDate;
         }
         dbcontext.SaveChanges();
         return(original);
     }
     catch (Exception)
     {
         throw new Exception("Error saving delegate dates");
     }
 }
Beispiel #9
0
        public bool UpdateTop3Supplier(List <TenderQuotation> tqlist, int currentyear)
        {
            string productIdtoUpdate            = tqlist[0].ProductId;
            List <TenderQuotation> originTQList = dbcontext.TenderQuotations.Where(m => m.ProductId == productIdtoUpdate && m.Year == currentyear).ToList();

            foreach (TenderQuotation k in originTQList)
            {
                k.Rank = null;
            }
            foreach (TenderQuotation i in tqlist)
            {
                foreach (TenderQuotation j in originTQList)
                {
                    if (i.SupplierId == j.SupplierId)
                    {
                        j.Rank = i.Rank;
                    }
                }
            }
            dbcontext.SaveChanges();
            return(true);
        }
        public async Task <IActionResult> Index(List <int> numlist)
        {
            PurchaseOrder po          = new PurchaseOrder();
            var           itemContext = from m in _context.Item.Include(p => p.Cat) where m.Cat.Supplier1 == supplierId || m.Cat.Supplier2 == supplierId || m.Cat.Supplier3 == supplierId select m;

            try
            {
                po.SupplierId   = supplierId;
                po.PurchaseDate = DateTime.Now.Date;
                _context.Add(po);
                await _context.SaveChangesAsync();

                var pocontext = from m in _context.PurchaseOrder select m;
                List <PurchaseOrder> polist = await pocontext.ToListAsync();

                int PoId = polist[polist.Count - 1].PoId;

                foreach (string s in idlist)
                {
                    PODetails pods = new PODetails();
                    pods.ItemId     = s;
                    pods.Item       = itemContext.Where(p => p.ItemId == s).ToList().First();
                    pods.PoId       = PoId;
                    pods.QtyOrdered = numlist[idlist.IndexOf(s)];
                    _context.Add(pods);
                    _context.SaveChanges();
                }
            }
            catch (Exception e)
            {
                System.Console.Write(e.ToString());
                return(NotFound());
            }
            List <PODetails> podlist = new List <PODetails>();

            idlist   = new List <string>();
            IsPosted = true;
            return(RedirectToAction(nameof(ViewOrderHistory)));
        }
Beispiel #11
0
 public AdjustmentVoucher SaveNewAdjustmentVoucher(AdjustmentVoucher av)
 {
     dbcontext.AdjustmentVouchers.Add(av);
     dbcontext.SaveChanges();
     return(av);
 }
Beispiel #12
0
 public bool SaveNewTransaction(Transaction t1)
 {
     dbcontext.Transactions.Add(t1);
     dbcontext.SaveChanges();
     return(true);
 }
Beispiel #13
0
 public Requisition SaveNewRequisition(Requisition req)
 {
     dbcontext.Requisitions.Add(req);
     dbcontext.SaveChanges();
     return(req);
 }
Beispiel #14
0
 public bool AddNewPurchaseRequestDetail(PurchaseRequestDetail prd1)
 {
     dbcontext.PurchaseRequestDetails.Add(prd1);
     dbcontext.SaveChanges();
     return(true);
 }