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 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);
        }
Esempio 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);
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "Id,Name,Cost,Quantity")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "Id,Name")] Intern intern)
        {
            if (ModelState.IsValid)
            {
                db.Interns.Add(intern);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(intern));
        }
        public ActionResult Create(Contact contact)
        {
            if (ModelState.IsValid)
            {
                db.Contacts.Add(contact);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(contact));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Email")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "Id,Name,Description,ItemCount,ItemPrice,Availability")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
Esempio n. 9
0
        public ActionResult Create([Bind(Include = "subcatId,CatId,Subcategoryname")] subcategory subcategory)
        {
            if (ModelState.IsValid)
            {
                db.subcategories.Add(subcategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CatId = new SelectList(db.categories, "categoryId", "categoryName", subcategory.CatId);
            return(View(subcategory));
        }
Esempio n. 10
0
        public ActionResult Create([Bind(Include = "Id,CustomerId,ProductId,OrderQuantity")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                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));
        }
Esempio n. 11
0
        protected void btnNew_Click(object sender, EventArgs e)
        {
            if (btnNew.Text == "New")
            {
                btnNew.CausesValidation = true;
                btnNew.Text             = "Save";
                panel1.Visible          = true;
            }
            else
            {
                btnNew.CausesValidation = false;
                btnNew.Text             = "New";

                using (SampleDBEntities entity = new SampleDBEntities())
                {
                    Customer customer = new Customer();
                    customer.CompanyName  = txtCompanyName.Text.Trim();
                    customer.ContactName  = txtContactName.Text.Trim();
                    customer.ContactTitle = txtContactTitle.Text.Trim();
                    customer.Address      = txtAddress.Text.Trim();
                    entity.Customers.Add(customer);
                    entity.SaveChanges();
                }

                panel1.Visible = false;

                GridView1.DataBind();

                txtAddress.Text      = "";
                txtCompanyName.Text  = "";
                txtContactName.Text  = "";
                txtContactTitle.Text = "";
            }
        }
Esempio n. 12
0
        public ActionResult uploadjson(HttpPostedFileBase filejson)
        {
            SampleDBEntities sd = new SampleDBEntities();

            {
                if (!filejson.FileName.EndsWith(".json"))
                {
                    ViewBag.errmsg = "Only JSON Type Files Allowed";
                }
                else
                {
                    filejson.SaveAs(Server.MapPath("~/empfolder/" + Path.GetFileName(filejson.FileName)));
                    StreamReader       reader   = new StreamReader(Server.MapPath("~/empfolder/" + Path.GetFileName(filejson.FileName)));
                    string             jsondata = reader.ReadToEnd();
                    List <empjsondata> emplist  = JsonConvert.DeserializeObject <List <empjsondata> >(jsondata);
                    foreach (var item in emplist)
                    {
                        @item.email.ToString();
                        @item.EmpName.ToString();
                        @item.salary.ToString();
                        sd.empjsondatas.Add(item);
                        sd.SaveChanges();
                    }
                    ViewBag.message = "Selected" + Path.GetFileName(filejson.FileName) + "File  Is Saved Successfully !";
                }
            }
            return(View("Index"));
        }
Esempio n. 13
0
        public void AddUserAccount(UserSignUpView user)
        {
            using (SampleDBEntities db = new SampleDBEntities())
            {
                SYSUser SU = new SYSUser();
                SU.LoginName             = user.LoginName;
                SU.PasswordEncryptedText = user.Password;
                SU.RowCreatedSYSUserID   = user.SYSUserID > 0 ? user.SYSUserID : 1;
                SU.RowModifiedSYSUserID  = user.SYSUserID > 0 ? user.SYSUserID : 1;;
                SU.RowCreatedDateTime    = DateTime.Now;
                SU.RowMOdifiedDateTime   = DateTime.Now;

                db.SYSUsers.Add(SU);
                db.SaveChanges();

                SYSUserProfile SUP = new SYSUserProfile();
                SUP.SYSUserID            = SU.SYSUserID;
                SUP.FirstName            = user.FirstName;
                SUP.LastName             = user.LastName;
                SUP.Gender               = user.Gender;
                SUP.RowCreatedSYSUserID  = user.SYSUserID > 0 ? user.SYSUserID : 1;
                SUP.RowModifiedSYSUserID = user.SYSUserID > 0 ? user.SYSUserID : 1;
                SUP.RowCreatedDateTime   = DateTime.Now;
                SUP.RowModifiedDateTime  = DateTime.Now;

                db.SYSUserProfiles.Add(SUP);
                db.SaveChanges();


                if (user.LOOKUPRoleID > 0)
                {
                    SYSUserRole SUR = new SYSUserRole();
                    SUR.LOOKUPRoleID         = user.LOOKUPRoleID;
                    SUR.SYSUserID            = user.SYSUserID;
                    SUR.IsActive             = true;
                    SUR.RowCreatedSYSUserID  = user.SYSUserID > 0 ? user.SYSUserID : 1;
                    SUR.RowModifiedSYSUserID = user.SYSUserID > 0 ? user.SYSUserID : 1;
                    SUR.RowCreatedDateTime   = DateTime.Now;
                    SUR.RowModifiedDateTime  = DateTime.Now;

                    db.SYSUserRoles.Add(SUR);
                    db.SaveChanges();
                }
            }
        }
Esempio n. 14
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();
     }
 }
Esempio n. 15
0
 private void EmpAdd(SampleDBEntities ctx, EmployeeModel emp)
 {
     ctx.Employees.Add(new Employee()
     {
         Name       = emp.name,
         Department = emp.department,
         Salary     = emp.salary
     });
     ctx.SaveChanges();
 }
Esempio n. 16
0
        private void EmpEdit(SampleDBEntities ctx, EmployeeModel emp)
        {
            var existingEmp = ctx.Employees.Where(s => s.ID == emp.id).FirstOrDefault <Employee>();

            if (existingEmp != null)
            {
                existingEmp.Name       = emp.name;
                existingEmp.Department = emp.department;
                existingEmp.Salary     = emp.salary;

                ctx.SaveChanges();
            }
        }
Esempio n. 17
0
 public string AddEmployee(Employee Emp)
 {
     if (Emp != null)
     {
         using (SampleDBEntities dataContext = new SampleDBEntities())
         {
             dataContext.Employees.Add(Emp);
             dataContext.SaveChanges();
             return("Employee Updated");
         }
     }
     else
     {
         return("Invalid Employee");
     }
 }
 /// <summary>
 /// Insert New Employee
 /// </summary>
 /// <param name="Employe"></param>
 /// <returns></returns>
 public string InsertCustomers(Customer Customer)
 {
     if (Customer != null)
     {
         using (SampleDBEntities Obj = new SampleDBEntities())
         {
             Obj.Customers.Add(Customer);
             Obj.SaveChanges();
             return("Employee Added Successfully");
         }
     }
     else
     {
         return("Employee Not Inserted! Try Again");
     }
 }
Esempio n. 19
0
 public string DeleteEmployee(Employee Emp)
 {
     if (Emp != null)
     {
         using (SampleDBEntities dataContext = new SampleDBEntities())
         {
             int no           = Convert.ToInt32(Emp.Id);
             var employeeList = dataContext.Employees.Where(x => x.Id == no).FirstOrDefault();
             dataContext.Employees.Remove(employeeList);
             dataContext.SaveChanges();
             return("Employee Deleted");
         }
     }
     else
     {
         return("Invalid Employee");
     }
 }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     //Validations code here
     //...............
     //To save in database
     using (var context = new SampleDBEntities()){
         context.PlaceInfoes.Add(new PlaceInfo()
         {
             Name        = txtName.Text,
             Address     = txtAddress.Text,
             City        = txtCity.Text,
             State       = txtState.Text,
             CountryId   = Convert.ToInt32(ddlCountry.SelectedValue),
             Geolocation = DbGeography.FromText("POINT( " + hdnLocation.Value + ")")
         });
         context.SaveChanges();
     }
 }
Esempio n. 21
0
 public string UpdateEmployee(Employee Emp)
 {
     if (Emp != null)
     {
         using (SampleDBEntities dataContext = new SampleDBEntities())
         {
             int no           = Convert.ToInt32(Emp.Id);
             var employeeList = dataContext.Employees.Where(x => x.Id == no).FirstOrDefault();
             employeeList.name     = Emp.name;
             employeeList.mobil_no = Emp.mobil_no;
             employeeList.email    = Emp.email;
             dataContext.SaveChanges();
             return("Employee Updated");
         }
     }
     else
     {
         return("Invalid Employee");
     }
 }
 /// <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>
    /// To add random data in database for testing
    /// </summary>
    void GenerateData()
    {
        Random random = new Random();
        double lat = 25.3294781, lng = 55.373236899999995;

        using (var context = new SampleDBEntities())
        {
            for (int i = 1; i < 100; i++)
            {
                context.PlaceInfoes.Add(new PlaceInfo()
                {
                    Name        = "Sample" + i,
                    Address     = "address" + i,
                    City        = "test city",
                    State       = "test state",
                    CountryId   = Convert.ToInt32(ddlCountry.SelectedValue),
                    Geolocation = DbGeography.FromText("POINT( " + (lng + random.NextDouble() * 1.55).ToString() + " " + (lat + random.NextDouble()).ToString() + ")")
                });
            }
            context.SaveChanges();
        }
    }
    /// <summary>
    /// To add random data in database for testing
    /// </summary>
    void GenerateData()
    {
        Random random = new Random();
        double lat = 25.3294781, lng = 55.373236899999995;
        using (var context = new SampleDBEntities())
        {

            for (int i = 1; i < 100; i++)
            {
                context.PlaceInfoes.Add(new PlaceInfo()
                {
                    Name = "Sample" + i,
                    Address = "address" + i,
                    City = "test city",
                    State = "test state",
                    CountryId = Convert.ToInt32(ddlCountry.SelectedValue),
                    Geolocation = DbGeography.FromText("POINT( " + (lng + random.NextDouble() * 1.55).ToString() + " " + (lat + random.NextDouble()).ToString() + ")")
                });
            }
            context.SaveChanges();
        }
    }
        /// <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");
            }
        }
Esempio n. 26
0
 public int Complete()
 {
     return(_context.SaveChanges());
 }
Esempio n. 27
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     db.SaveChanges();
 }
Esempio n. 28
0
 public void Save()
 {
     _dbContext.SaveChanges();
 }
Esempio n. 29
0
 public void Complete()
 {
     _context.SaveChanges();
 }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     //Validations code here
     //...............
     //To save in database
     using ( var context = new SampleDBEntities()){
         context.PlaceInfoes.Add (new PlaceInfo() {
         Name = txtName.Text,
         Address = txtAddress.Text,
         City = txtCity.Text,
         State = txtState.Text,
         CountryId = Convert.ToInt32 (ddlCountry.SelectedValue),
         Geolocation = DbGeography.FromText("POINT( " + hdnLocation.Value + ")")
         });
         context.SaveChanges();
     }
 }