Exemplo n.º 1
0
        public ActionResult DeleteConfirmed(string id)
        {
            Employee_Info employee_Info = db.Employee_Info.Find(id);

            db.Employee_Info.Remove(employee_Info);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Employee_Info employee_Info = await db.Employee_Info.FindAsync(id);

            db.Employee_Info.Remove(employee_Info);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,Fname,Lname,Role,DOB,Gender,Contact_No,Address")] Employee_Info employee_Info)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee_Info).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("EmpDetail", "Health_Info"));
     }
     return(View(employee_Info));
 }
Exemplo n.º 4
0
        public void refresh()
        {
            comboBox1.Items.Clear();
            List <int> id = new Employee_Info().Ret_Emp_Id();

            foreach (int ids in id)
            {
                comboBox1.Items.Add(ids.ToString());
            }
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "Fname,Lname,Role,DOB,Gender,Contact_No,Address")] Employee_Info employee_Info)
        {
            employee_Info.Id = User.Identity.GetUserId();
            if (ModelState.IsValid)
            {
                db.Employee_Info.Add(employee_Info);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee_Info));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Edit([Bind(Include = "Employee_Id,E_ID,Employee_Name,Theater_Id,Password,Email,Phone_No,Address")] Employee_Info employee_Info)
        {
            if (ModelState.IsValid)
            {
                db.Entry(employee_Info).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.Theater_Id = new SelectList(db.Theater_Info, "Theater_Id", "T_ID", employee_Info.Theater_Id);
            return(View(employee_Info));
        }
Exemplo n.º 7
0
        public ActionResult Employee(Employee_Info objUser)
        {
            using (projectEntities1 context = new projectEntities1())
            {
                string name = Session["UserName"].ToString();
                if (name == "admin")
                {
                    return(RedirectToAction("../Employee_Info/Index"));
                }
            }

            return(RedirectToAction("Dashboard"));
        }
Exemplo n.º 8
0
        // GET: Employee_Info/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employee_Info employee_Info = db.Employee_Info.Find(id);

            if (employee_Info == null)
            {
                return(HttpNotFound());
            }
            return(View(employee_Info));
        }
Exemplo n.º 9
0
        // GET: Employee_Info/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employee_Info employee_Info = await db.Employee_Info.FindAsync(id);

            if (employee_Info == null)
            {
                return(HttpNotFound());
            }
            return(View(employee_Info));
        }
Exemplo n.º 10
0
        // GET: Employee_Info/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employee_Info employee_Info = await db.Employee_Info.FindAsync(id);

            if (employee_Info == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Theater_Id = new SelectList(db.Theater_Info, "Theater_Id", "T_ID", employee_Info.Theater_Id);
            return(View(employee_Info));
        }
Exemplo n.º 11
0
 public ActionResult Login(Employee_Info objUser)
 {
     if (ModelState.IsValid)
     {
         using (projectEntities1 context = new projectEntities1())
         {
             var obj = context.Employee_Info.Where(a => a.Employee_Name.Equals(objUser.Employee_Name) && a.Password.Equals(objUser.Password)).FirstOrDefault();
             if (obj != null)
             {
                 Session["UserID"]   = obj.Employee_Id.ToString();
                 Session["UserName"] = obj.Employee_Name.ToString();
                 return(RedirectToAction("Dashboard"));
             }
         }
     }
     return(View(objUser));
 }
Exemplo n.º 12
0
        public IHttpActionResult AddEmployee(String token, String employeeJson)
        {
            var tokenLifetime = int.Parse(ConfigurationManager.AppSettings["tokenLifetime"]);
            var session       = db.Session_Tokens.FirstOrDefault((p) => (p.SessionToken == token && DbFunctions.DiffHours(DateTime.Now, p.Timestamp) < tokenLifetime));

            if (session != null)
            {
                var employee = db.Employee_Info.FirstOrDefault((p) => (p.CompanyId == session.CompanyId && p.EmployeeId == session.EmployeeId && p.IsAdmin == "y"));

                if (employee != null)
                {
                    try {
                        var newEmployee = new JavaScriptSerializer().Deserialize <EmployeeDataModel>(employeeJson);
                        var dbEmployee  = db.Employee_Info.FirstOrDefault((p) => (p.CompanyId == newEmployee.companyId && p.EmployeeId == newEmployee.employeeId));

                        if (dbEmployee == null)
                        {
                            var e = new Employee_Info {
                                CompanyId    = newEmployee.companyId,
                                EmployeeId   = newEmployee.employeeId,
                                EmployeeName = newEmployee.name,
                                DOJ          = newEmployee.date,
                                DOL          = null,
                                IsAdmin      = newEmployee.isAdmin,
                                Password     = newEmployee.password
                            };
                            db.Employee_Info.Add(e);

                            if (newEmployee.salary.FirstOrDefault((p) => (p.name == "Basic" && p.type == "#" && p.value > 0)) != null)
                            {
                                for (int i = 0; i < newEmployee.salary.Length; i++)
                                {
                                    if ((newEmployee.salary[i].type == "#") || (newEmployee.salary[i].type == "%" && newEmployee.salary[i].value <= 100))
                                    {
                                        var s = new Employee_Salary {
                                            CompanyId       = newEmployee.companyId,
                                            EmployeeId      = newEmployee.employeeId,
                                            AdjustmentName  = newEmployee.salary[i].name,
                                            AdjustmentType  = newEmployee.salary[i].type,
                                            AdjustmentValue = newEmployee.salary[i].value
                                        };
                                        db.Employee_Salary.Add(s);
                                    }
                                    else
                                    {
                                        return(Ok(new Message {
                                            data = null,
                                            message = "Salary data model contains invalid data"
                                        }));
                                    }
                                }

                                for (int i = 0; i < newEmployee.personal.Length; i++)
                                {
                                    if ((newEmployee.personal[i].name.Length != 0) && (newEmployee.personal[i].value.Length != 0))
                                    {
                                        var p = new Personal_Details {
                                            CompanyId  = newEmployee.companyId,
                                            EmployeeId = newEmployee.employeeId,
                                            Name       = newEmployee.personal[i].name,
                                            Value      = newEmployee.personal[i].value
                                        };
                                        db.Personal_Details.Add(p);
                                    }
                                    else
                                    {
                                        return(Ok(new Message {
                                            data = null,
                                            message = "Personal data model contains invalid data"
                                        }));
                                    }
                                }
                                db.SaveChangesAsync();

                                return(Ok(new Message {
                                    data = null,
                                    message = "Success"
                                }));
                            }
                            else
                            {
                                return(Ok(new Message {
                                    data = null,
                                    message = "Basic pay not found"
                                }));
                            }
                        }
                        else
                        {
                            return(Ok(new Message {
                                data = null,
                                message = "Employee already exists"
                            }));
                        }
                    } catch (System.ArgumentException) {
                        return(Ok(new Message {
                            data = null,
                            message = "JSON format is invalid"
                        }));
                    }
                }
                else
                {
                    return(Ok(new Message {
                        data = null,
                        message = "You do not have permission to perform this operation"
                    }));
                }
            }
            else
            {
                return(Ok(new Message {
                    data = null,
                    message = "Session Token is invalid"
                }));
            }
        }