Exemplo n.º 1
0
        public JsonResult AddProject(Project_Property Project)
        {
            if (ModelState.IsValid)
            {
                //add new employee
                if (Project.Project_Id == null || Project.Project_Id <= 0)
                {
                    Project.DateCreated = DateTime.Now;

                    Project.Status       = "Active";
                    Project.Is_Active    = true;
                    Project.In_Progress  = false;
                    Project.Is_Completed = false;

                    Project.Remarks = "";
                    objProjectBll   = new Project_BLL(Project);
                    var flag = objProjectBll.Insert();
                    if (flag)
                    {
                        return(Json(new { success = true, statuscode = 200, msg = "Successfully inserted" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet));
                    }
                }
                //when id <0 update case
                else
                {
                    Project.DateCreated = DateTime.Now;

                    Project.Status       = "Active";
                    Project.Is_Active    = true;
                    Project.In_Progress  = false;
                    Project.Is_Completed = false;

                    objProjectBll = new Project_BLL(Project);
                    var flag = objProjectBll.Update();
                    if (flag)
                    {
                        return(Json(new { success = true, statuscode = 200, msg = "Successfully inserted" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            //when model state is not valid
            else
            {
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();
                return(Json(new { success = false, statuscode = 500, msg = "Please Enter According To Instructions" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public JsonResult AddTask(Project_Property Project)
        {
            if (ModelState.IsValid)
            {
                EmployeeProperty objempproperty = new EmployeeProperty();
                objempproperty.Id = Project.Resource_Id;
                Employee_BLL objemployeebll = new Employee_BLL(objempproperty);
                DataTable    dt             = objemployeebll.SelectOne();
                foreach (DataRow dr in dt.Rows)
                {
                    Project.Employee_Cost = Math.Round(Convert.ToDecimal(dr["TotalSalary"].ToString()) / 270, 2);
                }
                //add new employee
                if (Project.Project_Id == null || Project.Project_Id <= 0)
                {
                    Project.DateCreated = DateTime.Now;

                    Project.Status       = "Active";
                    Project.Is_Active    = true;
                    Project.In_Progress  = false;
                    Project.Is_Completed = false;

                    Project.Remarks = "";

                    //Project.Employee_Cost=
                    objProjectBll = new Project_BLL(Project);
                    var flag = objProjectBll.InsertTask();
                    if (flag)
                    {
                        return(Json(new { success = true, statuscode = 200, msg = "Successfully inserted" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet));
                    }
                }
                //when id <0 update case
                else
                {
                    Project.DateCreated = DateTime.Now;

                    Project.Status = "Active";

                    objProjectBll = new Project_BLL(Project);
                    var flag = objProjectBll.Insert();
                    if (flag)
                    {
                        return(Json(new { success = true, statuscode = 200, msg = "Successfully inserted" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            //when model state is not valid
            else
            {
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();
                return(Json(new { success = false, statuscode = 500, msg = "Please Enter According To Instructions" }, JsonRequestBehavior.AllowGet));
            }
        }