public bool MapCustomer(RegisterViewModel model, string Id)
        {
            var customer = _dbContext.Customers.Where(x => x.Email == model.Email).SingleOrDefault();

            if (customer != null)
            {
                if (customer.UserId == null)
                {
                    customer.UserId = Id;
                }
                _dbContext.Entry(customer).State = EntityState.Modified;
                _dbContext.SaveChanges();
                return(true);
            }
            else
            {
                Validation.Data.Customer customer1 = new Validation.Data.Customer();
                customer1.Email  = model.Email;
                customer1.UserId = Id;
                _dbContext.Customers.Add(customer1);
                _dbContext.SaveChanges();
                return(true);
            }
            return(false);
        }
        public IHttpActionResult PutIntern(int id, Intern intern)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutCustomerTbl(long id, CustomerTbl customerTbl)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != customerTbl.CustomerID)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemple #4
0
 public void delete(int id)
 {
     using (var ctx = new SampleDBEntities())
     {
         var emp = ctx.Employees.Where(s => s.ID == id).FirstOrDefault();
         ctx.Entry(emp).State = System.Data.Entity.EntityState.Deleted;
         ctx.SaveChanges();
     }
 }
 public ActionResult Edit(Contact contact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contact));
 }
Exemple #6
0
 public ActionResult Edit([Bind(Include = "Id,Name,Description,ItemCount,ItemPrice,Availability")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
Exemple #7
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Email")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
Exemple #8
0
 public ActionResult Edit([Bind(Include = "Id,Name,Cost,Quantity")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
Exemple #9
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Intern intern)
 {
     if (ModelState.IsValid)
     {
         db.Entry(intern).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(intern));
 }
Exemple #10
0
 public ActionResult Edit([Bind(Include = "subcatId,CatId,Subcategoryname")] subcategory subcategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subcategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CatId = new SelectList(db.categories, "categoryId", "categoryName", subcategory.CatId);
     return(View(subcategory));
 }
 public ActionResult Edit([Bind(Include = "Id,CustomerId,ProductId,OrderQuantity")] Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerId = new SelectList(db.Customers, "Id", "FirstName", order.CustomerId);
     ViewBag.ProductId  = new SelectList(db.Products, "Id", "Name", order.ProductId);
     return(View(order));
 }
 /// <summary>
 /// Delete Employee Information
 /// </summary>
 /// <param name="Emp"></param>
 /// <returns></returns>
 public string DeleteCustomer(Customer Customer)
 {
     if (Customer != null)
     {
         using (SampleDBEntities Obj = new SampleDBEntities())
         {
             var Emp_ = Obj.Entry(Customer);
             if (Emp_.State == System.Data.Entity.EntityState.Detached)
             {
                 Obj.Customers.Attach(Customer);
                 Obj.Customers.Remove(Customer);
             }
             Obj.SaveChanges();
             return("Employee Deleted Successfully");
         }
     }
     else
     {
         return("Employee Not Deleted! Try Again");
     }
 }
        /// <summary>
        /// Update Employee Information
        /// </summary>
        /// <param name="Emp"></param>
        /// <returns></returns>
        public string UpdateCustomer(Customer Customer)
        {
            if (Customer != null)
            {
                using (SampleDBEntities Obj = new SampleDBEntities())
                {
                    var      Customers = Obj.Entry(Customer);
                    Customer CustObj   = Obj.Customers.Where(x => x.CustomerID == Customer.CustomerID).FirstOrDefault();
                    CustObj.Name      = Customer.Name;
                    CustObj.Address   = Customer.Address;
                    CustObj.EmailID   = Customer.EmailID;
                    CustObj.Birthdate = Customer.Birthdate;
                    CustObj.Mobileno  = Customer.Mobileno;

                    Obj.SaveChanges();
                    return("Employee Updated Successfully");
                }
            }
            else
            {
                return("Employee Not Updated! Try Again");
            }
        }
Exemple #14
0
 public void UpdateEmployee(Employee employee)
 {
     _dbContext.Entry(employee).State = EntityState.Modified;
 }
Exemple #15
0
 public void Update(TEntity entity)
 {
     dbset.Attach(entity);
     context.Entry(entity).State = EntityState.Modified;
 }