Example #1
0
 public JsonResult PublishWorkCalendar(int workCalendarId, int?TypeSelect)
 {
     try
     {
         UnitWorkCalendarDAL objCtrl = new UnitWorkCalendarDAL();
         UnitWorkCalendar    obj     = objCtrl.GetItemByID("Id", workCalendarId);
         if (obj.Id > 0)
         {
             obj.PublishedBy = SysBaseInfor.GetCurrentUserId();
             obj.PublishedAt = DateTime.Now;
             if (TypeSelect > 0)
             {
                 obj.Status = 0;
             }
             else
             {
                 obj.Status = 1;
             }
             objCtrl.UpdateItem(obj);
         }
         return(Json(new { Msg = "Success" }));
     }
     catch (Exception ex)
     {
         return(Json(new { Msg = "Fail" }));
     }
 }
Example #2
0
        public ActionResult ShowDetailUnitWorkCalendar(int workCalendarId, int?TypeSelect)
        {
            try
            {
                UnitWorkCalendarDAL WorkCalendarCtrl = new UnitWorkCalendarDAL();
                var vnFormat         = new CultureInfo("VI-vi");
                var listDayForSelect = new List <SelectListItem>();

                if (TypeSelect > 0)
                {
                    DateTime startOfWeek = DateTime.Today.AddDays(-1 * (int)(DateTime.Today.DayOfWeek) + 1);
                    DateTime endOfWeek   = startOfWeek.AddDays(5);

                    for (int tmpI = (int)DateTime.Today.DayOfWeek; tmpI < 7; tmpI++)
                    {
                        var tmpDow = DateTime.Today.AddDays(tmpI - (int)DateTime.Today.DayOfWeek);
                        listDayForSelect.Add(new SelectListItem()
                        {
                            Text = vnFormat.DateTimeFormat.GetDayName(tmpDow.DayOfWeek) + " " + tmpDow.ToString("dd/MM/yyyy"), Value = tmpDow.ToString()
                        });
                    }
                }
                else
                {
                    listDayForSelect.Add(new SelectListItem()
                    {
                        Text = vnFormat.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek) + " " + DateTime.Now.ToString("dd/MM/yyyy"), Value = DateTime.Now.ToString("MM/dd/yyyy")
                    });
                }

                ViewBag.ListDayForSelect = new SelectList(listDayForSelect, "Value", "Text");

                var roleManager = HttpContext.GetOwinContext().Get <ApplicationRoleManager>();
                ViewBag.ListGroupRoles = new SelectList(roleManager.GetListRoleByUnitIdAndType(SysBaseInfor.GetCurrentUnitCode() + SysBaseInfor.SignProject, SysBaseInfor.GetCurrentUnitId().ToInt32(), 2), "Id", "Name");

                var result = new UnitWorkCalendar();

                if (workCalendarId > 0)
                {
                    result = WorkCalendarCtrl.GetItemByID("Id", workCalendarId);
                }

                return(PartialView("~/Views/UnitWorkCalendar/_DetailUnitWorkCalendar.cshtml", result));
            }
            catch (Exception ex)
            {
                return(PartialView(blankViewUrl));
            }
        }