public IHttpActionResult PutLoanMaster(int id, LoanMaster loanMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != loanMaster.LoanID)
            {
                return(BadRequest());
            }

            db.Entry(loanMaster).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoanMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public void Send(string User1Id, string User2Id, string message)
        {
            int _User1Id = Int32.Parse(User1Id);
            int _User2Id = Int32.Parse(User2Id);

            int  chatId;
            Chat chat = db.Chats.Where(m => m.User1Id == _User1Id && m.User2Id == _User2Id).FirstOrDefault();

            if (chat == null)
            {
                chatId = db.Chats.Where(m => m.User1Id == _User2Id && m.User2Id == _User1Id).FirstOrDefault().Id;
            }
            else
            {
                chatId = chat.Id;
            }

            int     userId     = db.Users.Where(m => m.ConnectionId == Context.ConnectionId).FirstOrDefault().Id;
            Message newMessage = new Message {
                Text = message, Date = DateTime.Now, UserId = userId
            };

            db.Chats.Find(chatId).Messages.Add(newMessage);
            db.SaveChanges();


            Clients.Caller.addMessage(true, message, newMessage.HoursAndMinutes);
            Clients.Others.addMessage(false, message, newMessage.HoursAndMinutes);
        }
示例#3
0
        public IHttpActionResult PutBook(int id, Book book)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != book.Id)
            {
                return(BadRequest());
            }

            db.Entry(book).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(book));
        }
        public ActionResult Create([Bind(Include = "LoanID,LoanName,LoanDescription,LoanAmount,FromDate,InterestPercentage,CustomerID,AddedDate,AddedUser")] LoanMaster loanMaster)
        {
            if (ModelState.IsValid)
            {
                LoanPaymentDetail londet = new LoanPaymentDetail();
                londet.FromDate           = loanMaster.FromDate;
                londet.BalanceAmount      = loanMaster.LoanAmount;
                londet.IsCurrent          = true;
                londet.InterestPercentage = loanMaster.InterestPercentage;



                loanMaster.LoanPaymentDetails.Add(londet);



                db.LoanMasters.Add(loanMaster);


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "CustomerName", loanMaster.CustomerID);
            return(View(loanMaster));
        }
示例#5
0
        public IActionResult Eliminar(int id)
        {
            var productos = _context.Productos.FirstOrDefault(x => x.id == id);

            _context.Remove(productos);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Create(Customer customer)
 {
     if (ModelState.IsValid)
     {
         _context.Customers.Add(customer);
         _context.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
示例#7
0
 // clean up the db
 public override void Clear()
 {
     base.Clear();
     foreach (var cacheEntry in _db.PerUserCacheList)
     {
         _db.PerUserCacheList.Remove(cacheEntry);
     }
     _db.SaveChanges();
 }
示例#8
0
 public IActionResult Producto(Home p)
 {
     if (ModelState.IsValid)
     {
         _context.Add(p);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(p));
 }
示例#9
0
        public ActionResult Create([Bind(Include = "Id,Name")] Apprentice apprentice)
        {
            if (ModelState.IsValid)
            {
                db.Apprentices.Add(apprentice);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(apprentice));
        }
示例#10
0
        public ActionResult Create([Bind(Include = "ExpenseItemID,ExpenseItemName")] ExpenseItem expenseItem)
        {
            if (ModelState.IsValid)
            {
                db.ExpenseItems.Add(expenseItem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(expenseItem));
        }
示例#11
0
        public ActionResult Create([Bind(Include = "ID,CompanyName,Address,PhoneNumber")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                db.Suppliers.Add(supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supplier));
        }
示例#12
0
 public ActionResult Create(Model modelToCreate)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     modelToCreate.manuId = Request.Form["SelectID"];
     _db.Model.Add(modelToCreate);
     _db.SaveChanges();
     return(RedirectToAction("Create"));
 }
示例#13
0
        public ActionResult Create([Bind(Include = "ID,FirstName,LastName,UserName,Password,Mail,IsAdmin")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
示例#14
0
        public ActionResult Create(Manufacter manufacterToCreate)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            _db.Manufacter.Add(manufacterToCreate);
            _db.SaveChanges();
            return(View());
        }
示例#15
0
        public ActionResult Create([Bind(Include = "ID,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
示例#16
0
        public PurchaseInvoiceMaster AddPurchaseInvoicemaster(PurchaseViewModel str)
        {
            PurchaseInvoiceMaster pur = new PurchaseInvoiceMaster();

            pur.CustomerID         = str.CustomerID;
            pur.PurchaseInvoiceNum = str.SupplierInvoice;
            pur.PurchaseDate       = str.PurchaseDate;
            pur.InvoiceDate        = str.SupplierInvoiceDate;
            pur.TotalBill          = str.InvoiceValue;
            pur.TotalPaid          = str.InvoiceValue;
            pur.TotalDiscount      = 0;

            pur.StoreID = int.Parse(System.Web.HttpContext.Current.Session["storeid"].ToString());

            pur.AddedUser  = System.Web.HttpContext.Current.Session["username"].ToString();
            pur.AddedDate  = DateTime.Now;
            pur.IsDeleted  = false;
            pur.IsCommited = false;

            cntxt.PurchaseInvoicemasters.Add(pur);
            cntxt.SaveChanges();

            foreach (PurchasedetailViewModel strdet in str.purchasedetailViewModels)
            {
                PurchaseInvoiceDetail purchaseInvoiceDetail = new PurchaseInvoiceDetail();

                purchaseInvoiceDetail.PurchaseInvoicemasterID = pur.PurchaseInvoicemasterID;
                purchaseInvoiceDetail.CategoryID  = strdet.CategoryID;
                purchaseInvoiceDetail.ItemNameId  = strdet.ItemNameID;
                purchaseInvoiceDetail.ProductName = strdet.ProductDetails;
                purchaseInvoiceDetail.Qty         = strdet.TotalQty;
                purchaseInvoiceDetail.SerialNum   = strdet.Serial;
                purchaseInvoiceDetail.TotalPrice  = strdet.TotalPrice;
                purchaseInvoiceDetail.UnitCP      = strdet.UnitPrice;
                purchaseInvoiceDetail.UnitSP      = strdet.SellingPrice;
                purchaseInvoiceDetail.CGSTPercent = strdet.CGSTPercent;
                purchaseInvoiceDetail.SGSTPercent = strdet.SGSTPercent;


                purchaseInvoiceDetail.UnitCGSTCP = 0;
                purchaseInvoiceDetail.UnitSGSTSP = 0;
                purchaseInvoiceDetail.UserID     = 0;

                purchaseInvoiceDetail.AddedUser = System.Web.HttpContext.Current.Session["username"].ToString();
                purchaseInvoiceDetail.AddedDate = DateTime.Now;
                purchaseInvoiceDetail.IsDeleted = false;

                cntxt.PurchaseInvoiceDetails.Add(purchaseInvoiceDetail);
            }

            cntxt.SaveChanges();

            return(pur);
        }
示例#17
0
        public ActionResult Create([Bind(Include = "Id,login,role,password")] User user)
        {
            if (ModelState.IsValid)
            {
                db.User.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
示例#18
0
        public ActionResult Create([Bind(Include = "FirstName,LastName,email")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
示例#19
0
        public ActionResult Create([Bind(Include = "PersonID,Firstname,Surname,Age,Active,Birthday")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.People.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(person));
        }
示例#20
0
        public ActionResult Create([Bind(Include = "brandNo,brandName,NAVbrandName,BrandConfiance,Note")] Brand brand)
        {
            if (ModelState.IsValid)
            {
                db.Brand.Add(brand);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(brand));
        }
        public ActionResult Create([Bind(Include = "Id,ItemDesc,CategoryId,Isactive")] ItemName itemName)
        {
            if (ModelState.IsValid)
            {
                db.ItemNames.Add(itemName);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", itemName.CategoryId);
            return(View(itemName));
        }
示例#22
0
        [ResponseType(typeof(Lease))] // add new leasing detail
        public IHttpActionResult PostLease(Lease lease)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Lease.Add(lease);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = lease.Id }, lease));
        }
示例#23
0
        public ActionResult Create([Bind(Include = "ID,ProductName,ProductType,cost,ImageURL,Description,Amount,SupplierId")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SupplierId = new SelectList(db.Suppliers, "ID", "CompanyName", product.SupplierId);
            return(View(product));
        }
示例#24
0
 public ActionResult Create(Vehicle vehicleToCreate)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     vehicleToCreate.manuId  = Request.Form["manufacter"];
     vehicleToCreate.modelId = Request.Form["model"];
     vehicleToCreate.carId   = Request.Form["detail"];
     _db.Vehicle.Add(vehicleToCreate);
     _db.SaveChanges();
     return(RedirectToAction("Create"));
 }
 public ActionResult ChangeAmountOfViews(int publicationId)
 {
     if (User.Identity.IsAuthenticated)
     {
         if (db.Publications.Where(m => m.User.Email == User.Identity.Name).FirstOrDefault() != null)
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
     }
     db.Publications.Where(m => m.Id == publicationId).FirstOrDefault().AmountOfPageViews += 1;
     db.SaveChanges();
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
示例#26
0
        public ActionResult AssignArticle(int articleId, string detailId)
        {
            getArticleIdsWithState ga = new getArticleIdsWithState()
            {
                articleID = articleId,
                carID     = detailId,
                SortNo    = 1
            };

            db.getArticleIdsWithState.Add(ga);
            db.SaveChanges();

            return(RedirectToAction("Details", new { id = detailId }));
        }
示例#27
0
        public IActionResult Novo(NovoViewModel novo)
        {
            var produto = new Produto()
            {
                Nome       = novo.Nome,
                Descricao  = novo.Descricao,
                Valor      = novo.Valor,
                Quantidade = novo.Quantidade
            };

            db.Produtos.Add(produto);
            db.SaveChanges();

            return(RedirectToAction("Visualizar", new { Id = produto.Id }));
        }
        public ActionResult Create([Bind(Include = "ExpenseDetailID,ExpenseItemID,ExpenseDetailRemark,ExpenseDate,AddedDate,AddedUser,Deleteddate,DeletedUser,ModifiedDate,ModifiedUser,IsDeleted")] ExpenseDetail expenseDetail)
        {
            expenseDetail.AddedUser = HttpContext.Session["username"].ToString();
            expenseDetail.IsDeleted = false;
            expenseDetail.AddedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.ExpenseDetails.Add(expenseDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ExpenseItemID = new SelectList(db.ExpenseItems, "ExpenseItemID", "ExpenseItemName", expenseDetail.ExpenseItemID);
            return(View(expenseDetail));
        }
 public ActionResult Confirm(int?id, bool?value)
 {
     if (User.Identity.IsAuthenticated)
     {
         if (db.Users.Where(m => m.Email == User.Identity.Name && m.RoleId == 2).FirstOrDefault() != null)
         {
             if (id == null || value == null)
             {
                 return(HttpNotFound());
             }
             var publication = db.Publications.Where(m => m.Id == id).FirstOrDefault();
             if (publication != null)
             {
                 if (value == true)
                 {
                     publication.IsApprovedByAdmin = true;
                     publication.IsActive          = true;
                     db.Entry(publication).State   = EntityState.Modified;
                 }
                 else
                 {
                     db.Publications.Remove(publication);
                 }
                 db.SaveChanges();
             }
             return(RedirectToAction("UnconfirmedPublications"));
         }
     }
     return(HttpNotFound());
 }
示例#30
0
        public void DeleteCustomer(int id)
        {
            var customer = GetCustomerById(id);

            _context.Customers.Remove(customer);
            _context.SaveChanges();
        }