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);
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 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));
 }
Exemplo n.º 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));
 }
Exemplo n.º 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));
 }
Exemplo n.º 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));
 }
Exemplo n.º 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));
 }
Exemplo n.º 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));
 }
Exemplo n.º 11
0
 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");
            }
        }
Exemplo n.º 14
0
 public void UpdateEmployee(Employee employee)
 {
     _dbContext.Entry(employee).State = EntityState.Modified;
 }
Exemplo n.º 15
0
 public void Update(TEntity entity)
 {
     dbset.Attach(entity);
     context.Entry(entity).State = EntityState.Modified;
 }