public void AddProduct(Product product, int concernId, int userId)
 {
     product.CreationDate = DateTime.Now;
     product.ConcernId    = concernId;
     product.Creator      = userId;
     _context.Products.Add(product);
     _context.SaveChanges();
 }
Exemplo n.º 2
0
 public void AddExportIssue(ExportIssue exportIssue, int concernId, int userId)
 {
     exportIssue.ConcernId    = concernId;
     exportIssue.CreationDate = DateTime.Now;
     exportIssue.Creator      = userId;
     _context.ExportIssues.Add(exportIssue);
     _context.SaveChanges();
 }
        public ActionResult AddRegion(Region region)
        {
            var concernId = Convert.ToInt32(Session["ConcernId"]);
            var userId    = Convert.ToInt32(Session["UserId"]);

            if (concernId > 0 && userId > 0)
            {
                region.CreationDate = DateTime.Now;
                region.ConcernId    = userId;
                _context.Regions.Add(region);
                _context.SaveChanges();
                return(RedirectToAction(nameof(Region)));
            }
            return(RedirectToAction("LogIn", "GlobalData", new { Area = "Global" }));
        }
 public void AddMachine(int concernId, int userId, MachinePurchase machinePurchase)
 {
     machinePurchase.ConcernId    = concernId;
     machinePurchase.Creator      = userId;
     machinePurchase.CreationDate = DateTime.Now;
     _context.MachinePurchase.Add(machinePurchase);
     _context.SaveChanges();
 }
Exemplo n.º 5
0
 public void AddCompany(Company company, int concernId, int userId)
 {
     company.ConcerinId   = concernId;
     company.Creator      = userId;
     company.CreationDate = DateTime.Now;
     _context.Companies.Add(company);
     _context.SaveChanges();
 }
        public void ImportGoods(ImportGood importGood, int concernId, int userId)
        {
            var code        = importGood.ProductId + "" + importGood.ArticleId + "" + importGood.WidthId + "" + importGood.ConstructionId + "" + importGood.SoftnessId + "" + importGood.SourceId + "" + importGood.ColorId;
            var productCode = _context.ProductNames.FirstOrDefault(m => m.ProductCode == code);

            using (DbContextTransaction transaction = _context.Database.BeginTransaction())
            {
                if (productCode == null)
                {
                    ProductName product = new ProductName();
                    product.ProductCode    = code;
                    product.ProductId      = importGood.ProductId;
                    product.ArticleId      = importGood.ArticleId;
                    product.WidthId        = importGood.WidthId;
                    product.ConstructionId = importGood.ConstructionId;
                    product.SoftnessId     = importGood.SoftnessId;
                    product.SourceId       = importGood.SourceId;
                    product.ColorId        = importGood.ColorId;
                    _context.ProductNames.Add(product);
                    _context.SaveChanges();

                    importGood.ConcernId    = concernId;
                    importGood.Creator      = userId;
                    importGood.ProductCode  = code;
                    importGood.CreationDate = DateTime.Now;
                    _context.ImportGoods.Add(importGood);
                    _context.SaveChanges();

                    transaction.Commit();
                }
                else
                {
                    importGood.ConcernId    = concernId;
                    importGood.Creator      = userId;
                    importGood.ProductCode  = code;
                    importGood.CreationDate = DateTime.Now;
                    _context.ImportGoods.Add(importGood);
                    _context.SaveChanges();

                    transaction.Commit();
                }
            }
        }
        public JsonResult AddUser(SystemUser systemUser)
        {
            var chkUser = _context.SystemUsers.FirstOrDefault(m => m.EmailAddress == systemUser.EmailAddress);

            if (chkUser == null)
            {
                var    userId    = Convert.ToInt32(Session["UserId"]);
                var    concernId = Convert.ToInt32(Session["ConcernId"]);
                Helper helper    = new Helper();
                var    hashSalt  = helper.GenerateRandomSalt();
                var    password  = helper.HashPasswordUsingSHA2(systemUser.Password, hashSalt);
                systemUser.Password       = password;
                systemUser.CreatorId      = userId;
                systemUser.ConcernID      = concernId;
                systemUser.CreationDate   = DateTime.Now;
                systemUser.LoginDate      = DateTime.Now;
                systemUser.HashSalt       = hashSalt;
                systemUser.ActivationDate = DateTime.Now;
                _context.SystemUsers.Add(systemUser);
                _context.SaveChanges();
                return(Json("added successfully", JsonRequestBehavior.AllowGet));
            }
            return(Json("User name or email already exists", JsonRequestBehavior.AllowGet));
        }
 public void AddCashDetails(CashDetails cashDetails, int concernID, int userId, int code)
 {
     cashDetails.ConcernId    = concernID;
     cashDetails.Creator      = userId;
     cashDetails.CreationDate = DateTime.Now;
     cashDetails.SICode       = code.ToString();
     _context.CashDetails.Add(cashDetails);
     _context.SaveChanges();
 }
        public void AddOrderRawMaterial(OrderRawMaterial orderRawMaterial, int concernId, int userId, int orderId)
        {
            var code        = orderRawMaterial.ProductId + "" + orderRawMaterial.ArticleId + "" + orderRawMaterial.WidthId + "" + orderRawMaterial.ConstructionId + "" + orderRawMaterial.SoftnessId + "" + orderRawMaterial.SourceId + "" + orderRawMaterial.ColorId;
            var productCode = _context.ProductNames.FirstOrDefault(m => m.ProductCode == code);

            using (DbContextTransaction transaction = _context.Database.BeginTransaction())
            {
                if (productCode == null)
                {
                    ProductName product = new ProductName();
                    product.ProductCode    = code;
                    product.ProductId      = orderRawMaterial.ProductId;
                    product.ArticleId      = orderRawMaterial.ArticleId;
                    product.WidthId        = orderRawMaterial.WidthId;
                    product.ConstructionId = orderRawMaterial.ConstructionId;
                    product.SoftnessId     = orderRawMaterial.SoftnessId;
                    product.SourceId       = orderRawMaterial.SourceId;
                    product.ColorId        = orderRawMaterial.ColorId;
                    _context.ProductNames.Add(product);
                    _context.SaveChanges();

                    orderRawMaterial.ConcernId    = concernId;
                    orderRawMaterial.ProductCode  = code;
                    orderRawMaterial.Creator      = userId;
                    orderRawMaterial.CreationDate = DateTime.Now;
                    orderRawMaterial.OrderId      = orderId;
                    _context.OrderRawMaterials.Add(orderRawMaterial);
                    _context.SaveChanges();

                    transaction.Commit();
                }
                else
                {
                    orderRawMaterial.ConcernId    = concernId;
                    orderRawMaterial.ProductCode  = code;
                    orderRawMaterial.Creator      = userId;
                    orderRawMaterial.CreationDate = DateTime.Now;
                    orderRawMaterial.OrderId      = orderId;
                    _context.OrderRawMaterials.Add(orderRawMaterial);
                    _context.SaveChanges();

                    transaction.Commit();
                }
            }
        }