public IEnumerable <Intervention> fetchInterventionsByClientId(Guid clientId) { using (IMSEntities context = new IMSEntities()) { return(context.Interventions.Where(i => i.ClientId == clientId).ToList()); } }
public IEnumerable <Intervention> fetchInterventionsByApprovedUser(Guid userId) { using (IMSEntities context = new IMSEntities()) { return(context.Interventions.Where(i => i.ApprovedBy == userId).ToList()); } }
public IEnumerable <Intervention> fetchInterventionsByCreator(Guid creatorId) { using (IMSEntities context = new IMSEntities()) { return(context.Interventions.Where(i => i.CreatedBy == creatorId).ToList()); } }
public Intervention create(Intervention intervention) { using (IMSEntities context = new IMSEntities()) { Intervention newIntervention = new Intervention(intervention); context.Interventions.Add(newIntervention); context.SaveChanges(); return(newIntervention); // Intervention inter=context.Interventions.Add(new Intervention(intervention)); //try //{ // context.SaveChanges(); //} //catch (DbEntityValidationException dbEx) //{ // foreach (var validationErrors in dbEx.EntityValidationErrors) // { // foreach (var validationError in validationErrors.ValidationErrors) // { // Trace.TraceInformation("Property: {0} Error: {1}", // validationError.PropertyName, // validationError.ErrorMessage); // } // } //} //return (Intervention)context.Interventions.Find(intervention.Id); // return intervention; } }
public IEnumerable <User> getAll() { using (IMSEntities context = new IMSEntities()) { return(context.Users.ToList()); } }
public Client fetchClientById(Guid clientId) { using (IMSEntities context = new IMSEntities()) { return(context.Clients.Where(c => c.Id == clientId).FirstOrDefault()); } }
public IEnumerable <District> getAll() { using (IMSEntities context = new IMSEntities()) { return(context.Districts.ToList()); } }
public User fetchUserByName(string name) { using (IMSEntities context = new IMSEntities()) { return(context.Users.Where(u => u.Name == name).FirstOrDefault()); } }
public District fetchDistrictById(Guid districtId) { using (IMSEntities context = new IMSEntities()) { return(context.Districts.Where(d => d.Id == districtId).FirstOrDefault()); } }
public District fetchDistrictByName(string name) { using (IMSEntities context = new IMSEntities()) { return(context.Districts.Where(d => d.Name == name).FirstOrDefault()); } }
public IEnumerable <Client> getAll() { using (IMSEntities context = new IMSEntities()) { return(context.Clients.AsEnumerable()); } }
public IEnumerable <Intervention> fetchInterventionsByState(int state) { using (IMSEntities context = new IMSEntities()) { return(context.Interventions.Where(i => i.State == state).ToList()); } }
public User fetchUserById(Guid userId) { using (IMSEntities context = new IMSEntities()) { return(context.Users.Where(u => u.Id == userId).FirstOrDefault()); } }
public IEnumerable <Client> fetchClientsByDistrictId(Guid districtId) { using (IMSEntities context = new IMSEntities()) { return(context.Clients.Where(c => c.DistrictId == districtId).ToList()); } }
public BaseDL() { // ReSharper disable once InconsistentNaming var ensureDLLIsCopied = SqlProviderServices.Instance; IMSDB = new IMSEntities(); }
public IEnumerable <User> fetchUsersByUserType(int userType) { using (IMSEntities context = new IMSEntities()) { return(context.Users.Where(u => u.Type == userType).ToList()); } }
public IEnumerable <InterventionType> getAll() { using (IMSEntities context = new IMSEntities()) { return(context.InterventionTypes.ToList()); } }
public InterventionType fetchInterventionTypesById(Guid interventionTypeId) { using (IMSEntities context = new IMSEntities()) { return(context.InterventionTypes.Where(i => i.Id == interventionTypeId).FirstOrDefault()); } }
public ActionResult Authentication(string email, string password) { try { if (email != null && password != null) { using (IMSEntities db = new IMSEntities()) { var userAccount = db.UserAccounts.Where(u => u.Email == email).Where(u => u.Password == password).FirstOrDefault(); if (userAccount != null) { HttpContext.Session.Add("UserAccountID", userAccount.UserAccountID); HttpContext.Session.Add("UserTypeID", userAccount.UserTypeID); return(RedirectToAction("Index", "Home")); } else { throw new Exception("Invalid Email or Password"); } } } else { throw new Exception("Fields Empty"); } } catch (Exception e) { ViewBag.Error = e.Message; } return(View()); }
//public IEnumerable<Intervention> fetchInterventionsListById(Guid interventionId) //{ // using (IMSEntities context = new IMSEntities()) // { // return context.Interventions.Where(i => i.Id == interventionId).ToList(); // } //} public IEnumerable <Intervention> fetchInterventionsByInterventionType(Guid interventionTypeId) { using (IMSEntities context = new IMSEntities()) { return(context.Interventions.Where(i => i.InterventionTypeId == interventionTypeId).ToList()); } }
public User fetchUserByIdentityId(Guid identityId) { using (IMSEntities context = new IMSEntities()) { var x = context.Users.Where(u => u.IdentityId == identityId.ToString()).FirstOrDefault(); return(x); } }
public IEnumerable <Intervention> fetchInterventionsByDistrict(Guid districtId) { using (IMSEntities context = new IMSEntities()) { var clientId = context.Clients.Where(c => c.DistrictId == districtId).FirstOrDefault().Id; return(context.Interventions.Where(i => i.ClientId == clientId).ToList()); } }
public static IMSEntities getConnection() { if (db == null) { db = new IMSEntities(); } return db; }
public async Task <ActionResult> Create([Bind(Include = "ProductSalesID,ProductID,SalesID,Quantity,DateCreated,DateModified,ModifiedBy")] ProductSales productSales) { try { if (ModelState.IsValid) { var quantityRequest = productSales.Quantity; var result = db.Stock.Where(p => p.ProductID == productSales.ProductID).FirstOrDefault(); var quantityRemaning = result.QuantityRemaining; //if remaining qunatity >= requested quantity if (quantityRemaning >= quantityRequest) { if (productSales.DateCreated == null) { productSales.DateCreated = DateTime.Now; } if (productSales.DateModified == null) { productSales.DateModified = DateTime.Now; } productSales.ModifiedBy = Convert.ToInt32(HttpContext.Session["UserAccountID"]); db.ProductSales.Add(productSales); db.SaveChanges(); using (IMSEntities db = new IMSEntities()) { int productId = productSales.ProductID; var quantity = productSales.Quantity; var product = QueryHelper.GetProductPrice(db, productId).FirstOrDefault(); var totalAmount = quantity * product.PricePerItem; var bill = productSales.SalesID; await QueryHelper.UpdateBillingAmount(db, totalAmount, bill); var quantityremaining = QueryHelper.GetQuantity(db, productId).FirstOrDefault(); var totalquantityremaining = quantityremaining.QuantityRemaining - quantity; await QueryHelper.UpdateQuantityRemaining(db, totalquantityremaining, productId); } } else { throw new Exception("Insufficient item in the stock"); } } return(RedirectToAction("Index")); } catch (Exception e) { ViewBag.Error = e.Message; } ViewBag.ProductID = new SelectList(db.Product, "ProductID", "ProductName", productSales.ProductID); ViewBag.ModifiedBy = new SelectList(db.UserAccounts, "UserAccountID", "Email", productSales.ModifiedBy); ViewBag.SalesID = new SelectList(db.Sales, "SalesID", "SalesID", productSales.SalesID); return(View(productSales)); }
public User createUser(User user) { using (IMSEntities context = new IMSEntities()) { context.Users.Add(new User(user)); context.SaveChanges(); return(context.Users.Find(user)); } }
public InterventionType create(InterventionType interventionType) { using (IMSEntities context = new IMSEntities()) { context.InterventionTypes.Add(new InterventionType(interventionType)); context.SaveChanges(); return(context.InterventionTypes.Find(interventionType)); } }
public District create(District district) { using (IMSEntities context = new IMSEntities()) { context.Districts.Add(new District(district)); context.SaveChanges(); return(context.Districts.Find(district)); } }
public Client createClient(Client client) { using (IMSEntities context = new IMSEntities()) { Client newClient = new Client(client); context.Clients.Add(newClient); context.SaveChanges(); return(newClient); } }
public bool update(InterventionType interventionType) { using (IMSEntities context = new IMSEntities()) { var old = context.InterventionTypes.Where(i => i.Id == interventionType.Id).FirstOrDefault(); context.Entry(old).CurrentValues.SetValues(interventionType); if (context.SaveChanges() > 0) { return(true); } return(false); } }
public static IEnumerable <Stock> GetQuantity(IMSEntities db, int ProductID) { SqlParameter proParam = new SqlParameter("ProductID", ProductID); string objs = @" SELECT * FROM Stock WHERE ProductID = @ProductID"; object[] parameters = new object[] { proParam }; var result = db.Database.SqlQuery <Stock>(objs, parameters); return(result); }
public bool updateUser(User user) { using (IMSEntities context = new IMSEntities()) { var old = context.Users.Where(u => u.Id == user.Id).FirstOrDefault(); context.Entry(old).CurrentValues.SetValues(user); if (context.SaveChanges() > 0) { return(true); } return(false); } }
private void ProductsCategories_Load(object sender, EventArgs e) { db = CommonUtilities.getConnection(); setDropDownValues(comboBox_existingCategories); setDropDownValues(comboBox_existingProductCategories); setDropDownValues(comboBox_modifyExistingCategories); setDropDownValues(comboBox_editCategories); }