Example #1
0
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employee.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        //public ActionResult Create(FormCollection collection)
        public ActionResult Create(Clientes emp)
        {
            try
            {
                // TODO: Add insert logic here

                /*
                 * Clientes emp = new Models.Clientes();
                 * emp.nombre = collection["nombre"];
                 * DateTime jDate;
                 * DateTime.TryParse(collection["DOB"], out jDate);
                 * emp.FechaAlta = jDate;
                 * string edad = collection["edad"];
                 * emp.edad = Int32.Parse(edad);
                 * empList.Add(emp);
                 */

                db.Clientes.Add(emp);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #3
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Employee employee = new Employee();

                employee.Id           = Guid.NewGuid().ToString();
                employee.Name         = collection.Get("Name");
                employee.Title        = collection.Get("Title");
                employee.ProfileImage = collection.Get("ProfileImage");
                employee.Motto        = collection.Get("Motto");
                employee.Hobbies      = collection.Get("Hobbies");
                employee.Hometown     = collection.Get("Hometown");
                employee.Blog         = collection.Get("Blog");

                db.Employees.Add(employee);
                db.SaveChanges();

                return(Json(
                           new
                {
                    Success = true
                }
                           ));
            }
            catch
            {
                return(Json(
                           new
                {
                    Success = false
                }
                           ));
            }
        }
Example #4
0
        public ActionResult Create(Employee emp)
        {
            db.Employees.Add(emp);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #5
0
        public bool Create(Employee employee)
        {
            _db.EmployeeModels.Add(employee);

            _db.SaveChanges();

            return(true);
        }
Example #6
0
        public ActionResult Create([Bind(Include = "ID,Name,JoiningDate,Age")] ScaffoldingDemoEmployeeClass scaffoldingDemoEmployeeClass)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(scaffoldingDemoEmployeeClass);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(scaffoldingDemoEmployeeClass));
        }
Example #7
0
        public ActionResult Create([Bind(Include = "ID,nombre,FechaAlta,edad")] Clientes clientes)
        {
            if (ModelState.IsValid)
            {
                db.Clientes.Add(clientes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clientes));
        }
Example #8
0
        public ActionResult Create([Bind(Include = "Id,Name,CreatedOn,Age")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
        public ActionResult Create([Bind(Include = "ID,Name,JoiningDate,Age")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
Example #10
0
 public ActionResult Create(Car c)
 {
     try
     {
         db.Cars.Add(c);
         db.SaveChanges();
         return(RedirectToAction("CarList"));
     }
     catch
     {
         return(View());
     }
 }
Example #11
0
 public ActionResult Create(Employee emp)
 {
     try
     {
         db.Employees.Add(emp);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public ActionResult Create(Clientes emp)
 {
     try
     {
         // TODO: Add insert logic here
         db.Clientes.Add(emp);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #13
0
 public ActionResult Create(Client client)
 {
     try
     {
         // clientList.Add(client);
         db.Clients.Add(client);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #14
0
        public ActionResult Create(Clientes newClient)
        {
            try
            {
                db.Clientes.Add(newClient);
                db.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(EmployeeSalaryModel EmployeeSalary)
        {
            try
            {
                EmployeeSalary.EmployeeSelectList = employeeService.GetSelectListItems();
                db.EmployeeSalary.Add(EmployeeSalary);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View(EmployeeSalary));
            }
        }
        public static void CreateNewUserstories(Userstories userstory)
        {
            EmpDBContext db = new EmpDBContext();

            db.userstories.Add(userstory);
            db.SaveChanges();
        }
        public static void CreateNewEmployee(Employee Emp)
        {
            EmpDBContext db = new EmpDBContext();

            db.Employees.Add(Emp);
            db.SaveChanges();
        }
Example #18
0
        public static void CreateTask(ProjectTask task)
        {
            EmpDBContext db = new EmpDBContext();

            db.ProjectTasks.Add(task);
            db.SaveChanges();
        }
Example #19
0
        public ActionResult Create(Employee emp) //pass form collection as param for manual binding
        {
            try
            {
                db.Employees.Add(emp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
                //model binding...pass the name of the target model for model binder
                //empList.Add(emp);
                //return RedirectToAction("Index");

                //these below params are used when we use form collection instead of model binder(Manual binding)
                //Employee emp = new Employee();
                //emp.Name = collection["Name"];
                //DateTime jDate;
                //DateTime.TryParse(collection["DOB"], out jDate);
                //emp.JoiningDate = jDate;
                //string age = collection["Age"];
                //emp.age = Int32.Parse(age);
                //empList.Add(emp); return RedirectToAction("Index");
            }
            catch
            {
                return(View());
            }
        }
        public static void Create(ManagerComment comment)
        {
            EmpDBContext db = new EmpDBContext();

            db.ManagerComments.Add(comment);
            db.SaveChanges();
        }
        public static void CreateNewProject(Project prjct)
        {
            EmpDBContext db = new EmpDBContext();

            db.Project.Add(prjct);
            db.SaveChanges();
        }
        public static void Delete(ManagerComment comment)
        {
            EmpDBContext db = new EmpDBContext();

            db.ManagerComments.Remove(comment);
            db.SaveChanges();
        }
Example #23
0
        public static void Delete(ProjectTask ts)
        {
            EmpDBContext db = new EmpDBContext();
            ProjectTask  tk = SearchById(ts, db);

            db.ProjectTasks.Remove(tk);
            db.SaveChanges();
        }
Example #24
0
        public ActionResult Create(Clientes emp)
        {
            try
            {
                //Ejemplo Model Binding
                //empList.Add(emp);

                db.Clientes.Add(emp); // Entity Framework: se cambia la recepcion de datos
                db.SaveChanges();     // guarda los datos que hermos realizados

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public static void Edit(ManagerComment comment)
        {
            EmpDBContext   db = new EmpDBContext();
            ManagerComment c  = Search(comment, db);

            c.comments = comment.comments;
            c.taskid   = comment.taskid;
            db.SaveChanges();
        }
        public static void EditUserstories(Userstories e)
        {
            EmpDBContext db  = new EmpDBContext();
            Userstories  usr = SearchUserById(e, db);

            usr.story = e.story;
            usr.proid = e.proid;

            db.SaveChanges();
        }
        public static void DeleteAllProject(int proid)
        {
            EmpDBContext db     = new EmpDBContext();
            var          delete = db.Project.FirstOrDefault(s => s.proid == proid);

            if (delete != null)
            {
                db.Project.Remove(delete);
                db.SaveChanges();
            }
        }
        public static void DeleteallUserstories(int userstoryid)
        {
            EmpDBContext db     = new EmpDBContext();
            var          delete = db.userstories.FirstOrDefault(s => s.userstoryid == userstoryid);

            if (delete != null)
            {
                db.userstories.Remove(delete);
                db.SaveChanges();
            }
        }
        public void SendMessagetoFriend(MessageModel NewMessage)
        {
            //User definded data
            NewMessage.SentBy         = cUserID;
            NewMessage.SentByUsername = cUsername;
            NewMessage.SentTime       = DateTime.Now;

            //Add user to database
            db.Message.Add(NewMessage);
            db.SaveChanges();
        }
        public static void DeleteAllEmployee(int eid)
        {
            EmpDBContext db     = new EmpDBContext();
            var          delete = db.Employees.FirstOrDefault(s => s.eid == eid);

            if (delete != null)
            {
                db.Employees.Remove(delete);
                db.SaveChanges();
            }
        }