Example #1
0
        public ActionResult Create([Bind(Include = "ID,FacultyType,EMP_ID,External_Name,PAN_No,ServiceTaxNo,Qualification,Contact,Email,Remark,IsActive,Empty")] HRMS_Faculty_MS hRMS_Faculty_MS)
        {
            if (ModelState.IsValid)
            {
                if (hRMS_Faculty_MS.FacultyType == "Internal" && hRMS_Faculty_MS.EMP_ID != null)
                {
                    bool IsExist = db.HRMS_Faculty_MS.Any(x => x.EMP_ID == hRMS_Faculty_MS.EMP_ID);
                    if (IsExist)
                    {
                        ViewBag.error = "Faculty type already assigned to this Employee!";
                        ModelState.Clear();
                        return(View());
                    }
                    else
                    {
                        HRMS_Emp_Details obj  = db.HRMS_Emp_Details.Where(x => x.EMP_ID == hRMS_Faculty_MS.EMP_ID).FirstOrDefault();
                        string           name = obj.First_Name + " " + obj.Last_Name;
                        hRMS_Faculty_MS.External_Name = name;
                        db.HRMS_Faculty_MS.Add(hRMS_Faculty_MS);
                        db.SaveChanges();
                        ModelState.Clear();
                        ViewBag.success = "Successfully Faculty type assigned to this Employee!";
                        return(View());
                    }
                }
                db.HRMS_Faculty_MS.Add(hRMS_Faculty_MS);
                db.SaveChanges();
                ModelState.Clear();
                ViewBag.success = "Successfully Faculty type assigned to this Employee!";
                return(View());
            }

            return(View(hRMS_Faculty_MS));
        }
Example #2
0
        public ActionResult Edit([Bind(Include = "ID,FacultyType,EMP_ID,External_Name,PAN_No,ServiceTaxNo,Qualification,Contact,Email,Remark,IsActive,Empty")] HRMS_Faculty_MS hRMS_Faculty_MS)
        {
            if (ModelState.IsValid)
            {
                if (hRMS_Faculty_MS.EMP_ID != null)
                {
                    bool IsExist = db.HRMS_Faculty_MS.Any(x => (x.ID != hRMS_Faculty_MS.ID) && (x.EMP_ID == hRMS_Faculty_MS.EMP_ID));
                    if (!IsExist)
                    {
                        db.Entry(hRMS_Faculty_MS).State = EntityState.Modified;
                        db.SaveChanges();
                        ViewBag.success = "Data Successfully changed!";
                        return(View(hRMS_Faculty_MS));
                    }
                    else
                    {
                        ViewBag.error = "Record Already Exist!";
                        return(View(hRMS_Faculty_MS));
                    }
                }

                else
                {
                    db.Entry(hRMS_Faculty_MS).State = EntityState.Modified;
                    db.SaveChanges();
                    ViewBag.success = "Data Successfully changed!";
                    return(View(hRMS_Faculty_MS));
                }
            }
            return(View(hRMS_Faculty_MS));
        }
Example #3
0
        public JsonResult AddFacultyy(string facid, string proid)
        {
            db.Configuration.ProxyCreationEnabled = false;

            //adding into table
            long fac_id = Convert.ToInt64(facid);
            long pro_id = Convert.ToInt64(proid);

            bool IsExist = db.HRMS_ProgramFaculty.Any(x => x.ProgramID == pro_id && x.FacultyID == fac_id);

            if (!IsExist)
            {
                HRMS_Faculty_MS obj = db.HRMS_Faculty_MS.Where(x => x.ID == fac_id).FirstOrDefault();

                HRMS_ProgramFaculty obj1 = new HRMS_ProgramFaculty();
                obj1.FacultyID   = fac_id;
                obj1.FacultyName = obj.External_Name;
                obj1.Email       = obj.Email;
                obj1.ProgramID   = pro_id;

                db.HRMS_ProgramFaculty.Add(obj1);
                db.SaveChanges();


                //List<HRMS_ProgramFaculty> FacList = db.HRMS_ProgramFaculty.Where(x => x.ProgramID == pro_id).ToList();
                var FacList = pro_id;
                return(Json(FacList, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var FacList = "Faculty Already Exist!";
                return(Json(FacList, JsonRequestBehavior.AllowGet));
            }
        }
Example #4
0
        // GET: FacultyMaster/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HRMS_Faculty_MS hRMS_Faculty_MS = db.HRMS_Faculty_MS.Find(id);

            if (hRMS_Faculty_MS == null)
            {
                return(HttpNotFound());
            }
            return(View(hRMS_Faculty_MS));
        }
Example #5
0
        // GET: FacultyMaster/Delete/5
        public bool Delete(long id)
        {
            HRMS_Faculty_MS employee_Personal_Detail = db.HRMS_Faculty_MS.Find(id);

            if (employee_Personal_Detail != null)
            {
                db.HRMS_Faculty_MS.Remove(employee_Personal_Detail);
                db.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }