コード例 #1
0
ファイル: DefinationController.cs プロジェクト: swigithub/MVC
        public JsonResult ToSingle(string Filter, string Value)

        {
            PM_ProjectBL         pd = new PM_ProjectBL();
            PM_GazetteHolidaysBL gh = new PM_GazetteHolidaysBL();
            PM_TaskStagesBL      pM_TaskStagesBL = new PM_TaskStagesBL();
            var rec = pd.ToSingle(Filter, Value);

            if (Value != "0")
            {
                var ghh = gh.ToList("ByProjectId", Value);
                if (ghh.Count > 0)
                {
                    rec.GH = ghh;
                }
                var obj = pM_TaskStagesBL?.ToList("GetByProjectId", long.Parse(Value));
                if (obj.Count > 0)
                {
                    rec.TS = obj;
                }
            }



            //  rec.TS = pM_TaskStagesBL?.ToList("GetByProjectId", long.Parse(Value));
            return(Json(rec, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
ファイル: DefinationController.cs プロジェクト: swigithub/MVC
        public ActionResult New(PM_Project p)
        {
            Response   res   = new Response();
            AL_AlertBL model = new AL_AlertBL();

            try
            {
                // Insert Project Status Change Notification - Start
                AL_GetAlertSubscription Temp = new AL_GetAlertSubscription();
                Temp = model.IsSubscribed("IsSubscribed", (int)ViewBag.UserId, 0, (int)p.ProjectId, "Project Status Change");
                if (Temp.IsSubscribed)
                {
                    int status = model.InsertAlert("Insert_Alert", (int)p.ProjectId, (int)ViewBag.UserId, 0, (int)p.ProjectId, "Project Status Change", (int)p.StatusId);
                }
                // Insert Project Status Change Notification - End

                int                  x               = 0;
                PM_ProjectBL         pb              = new PM_ProjectBL();
                PM_GazetteHolidaysBL gh              = new PM_GazetteHolidaysBL();
                PM_WorkGroupsBL      PWG             = new PM_WorkGroupsBL();
                PM_TaskStagesBL      pM_TaskStagesBL = new PM_TaskStagesBL();
                if (p.WorkingDays != null)
                {
                    p.WorkingDays = p.WorkingDays.Substring(0, p.WorkingDays.Length - 1);
                }
                if (p.ProjectId > 0)
                {
                    pb.Manage("Update", p);

                    Int64 UID = ViewBag.UserId;
                    pb.ProjectUserPermission("UpdateUserPermissions", p.ManagerId, p.ProjectId);
                    //pb.ProjectUserPermission("UpdateUserPermissions", UID, p.ProjectId);
                    Permission.UpdateEntity(ViewBag.UserId);
                    PWG.Manage("Insert", p.ProjectId, p.WorkGroups);
                    if (p.GH != null)
                    {
                        p.GH[0].ProjectId = p.ProjectId;
                        gh.Manage("Delete", p.GH[0]);
                        gh.InsertBulk(p.ProjectId, p.GH);
                    }
                    else
                    {
                        PM_GazetteHolidays g = new PM_GazetteHolidays();
                        g.ProjectId = p.ProjectId;
                        g.Date      = DateTime.Now;
                        gh.Manage("Delete", g);
                        pb.ProjectUserPermission("UpdateUserPermissions", p.ManagerId, p.ProjectId);
                        //pb.ProjectUserPermission("UpdateUserPermissions", UID, p.ProjectId);
                        Permission.UpdateEntity(ViewBag.UserId);
                    }

                    // Update AND Add Task Stages
                    if (p.TS?.Count > 0)
                    {
                        bool IsEXE = pM_TaskStagesBL.UpdateOrAdd("UpdateOrAdd", p.ProjectId, p.TS);
                    }



                    res.Message = "Update successfully";
                }
                else
                {
                    p.IsActive = true;
                    var PId = pb.Manage("Insert", p);
                    PWG.Manage("Insert", PId, p.WorkGroups);

                    Int64 UID = ViewBag.UserId;
                    pb.ProjectUserPermission("InsertUserPermissions", p.ManagerId, PId);
                    pb.ProjectUserPermission("InsertUserPermissions", UID, PId);
                    Permission.UpdateEntity(ViewBag.UserId);
                    if (p.GH != null)
                    {
                        gh.InsertBulk(PId, p.GH);
                    }

                    if (p?.TS?.Count > 0)
                    {
                        var IsInserted = pM_TaskStagesBL.InsertBulk(PId, p.TS);
                    }
                    res.Value = PId;
                    Permission.AddProject(PId);
                    res.Message = "Save successfully";
                }
                res.Status = "success";
            }
            catch (Exception ex)
            {
                res.Status = "danger";
                if (ex.Message == "Object cannot be cast from DBNull to other types.")
                {
                    res.Message = "You Can't Insert Project who is already entered with same name and same client ";
                }
                else
                {
                    res.Message = ex.Message;
                }
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }