public ActionResult ProcessRequestAssignIp(ProcessRequestAssignIPViewModel viewmodel)
 {
     if (Request.Form[Constants.FormAction.ACCEPT_ACTION] != null)
     {
         var shifthead = GetCurrentUserName();
         var result = RequestBLO.Current.AcceptRequest(viewmodel.RequestInfo.RequestCode, shifthead,
             viewmodel.RequestInfo.Assignee, Constants.StatusCode.REQUEST_PROCESSING,
             Constants.TypeOfLog.LOG_ASSIGN_IP, true);
         var task = RequestBLO.Current.AssignTask(viewmodel.RequestInfo.RequestCode, shifthead,
             viewmodel.RequestInfo.Assignee);
         //dang ky ham cho client
         Notify(result.NotificationCodes);
         if (viewmodel.RequestInfo.Assignee != shifthead)
         {
             Notify(task.NotificationCodes);
         }
         return RedirectToAction("Detail", "ProcessRequest",
             new { code = viewmodel.RequestInfo.RequestCode, msg = Constants.Message.ACCEPT_REQUEST_ASSIGN_IP });
     }
     if (Request.Form[Constants.FormAction.APPROVE_ACTION] != null)
     {
         //get ip
         var ips = viewmodel.IPsString;
         var tokens = ips.Split(';').ToList();
         var msg = Constants.Message.APPROVE_REQUEST_ASSIGN_IP;
         //validate realtime
         var check = IPAddressPoolBLO.Current.CheckExistedIPs(tokens);
         if (check)
         {
             msg = "You're fooled";
         }
         else
         {
             var result = RequestBLO.Current.ApproveRequestAssignIP(viewmodel.RequestInfo.RequestCode, tokens,
            viewmodel.RequestInfo.Assignee, viewmodel.RequestInfo.TaskCode, viewmodel.SelectedServer);
             Notify(result.NotificationCodes);
         }
         //dang ky ham cho client
         return RedirectToAction("Detail", "ProcessRequest",
             new { code = viewmodel.RequestInfo.RequestCode, msg });
     }
     if (Request.Form[Constants.FormAction.REJECT_ACTION] != null)
     {
         var assignee = viewmodel.RequestInfo.Assignee;
         if (viewmodel.RequestInfo.Assignee == null)
         {
             assignee = GetCurrentUserName();
         }
         var result = RequestBLO.Current.RejectRequestAssignIP(viewmodel.RequestInfo.RequestCode,
             assignee, viewmodel.RequestInfo.Assignee, viewmodel.RequestInfo.Reason);
         //dang ky ham cho client
         Notify(result.NotificationCodes);
         return RedirectToAction("Detail", "ProcessRequest",
             new { code = viewmodel.RequestInfo.RequestCode, msg = Constants.Message.REJECT_REQUEST_ASSIGN_IP });
     }
     if (Request.Form[Constants.FormAction.REASSIGN_ACTION] != null)
     {
         var shifthead = GetCurrentUserName();
         if (viewmodel.RequestInfo.TaskStatus != Constants.StatusCode.TASK_NOTFINISH)
         {
             var preTask = RequestBLO.Current.CancelTask(viewmodel.RequestInfo.TaskCode,
             viewmodel.RequestInfo.RequestCode, viewmodel.RequestInfo.Assignee, shifthead);
             //dang ky ham cho client
             if (viewmodel.RequestInfo.Assignee != shifthead)
             {
                 Notify(preTask.NotificationCodes);
             }
         }
         var newTask = RequestBLO.Current.ReAssignTask(viewmodel.RequestInfo.TaskCode, viewmodel.RequestInfo.RequestCode,
             viewmodel.RequestInfo.Assignee, viewmodel.RequestInfo.AssignedStaff, shifthead);
         //dang ky ham cho client
         if (viewmodel.RequestInfo.AssignedStaff != shifthead)
         {
             Notify(newTask.NotificationCodes);
         }
         var message = Constants.Message.REASSIGN_TASK + viewmodel.RequestInfo.AssignedStaffName;
         return RedirectToAction("Detail", "ProcessRequest",
             new { code = viewmodel.RequestInfo.RequestCode, msg = message });
     }
     if (Request.Form[Constants.FormAction.ACCEPT_TASK_ACTION] != null)
     {
         //update task
         TaskBLO.Current.UpdateTaskStatus(viewmodel.RequestInfo.TaskCode, Constants.StatusCode.TASK_DOING);
         return RedirectToAction("Detail", "ProcessRequest",
             new { code = viewmodel.RequestInfo.RequestCode, msg = Constants.Message.ACCEPT_TASK });
     }
     if (Request.Form[Constants.FormAction.NOT_FINISHED_TASK_ACTION] != null)
     {
         var result = RequestBLO.Current.NotFinishRequest(viewmodel.RequestInfo.TaskCode, viewmodel.RequestInfo.NotFinishReason);
         Notify(result.NotificationCodes);
         return RedirectToAction("Detail", "ProcessRequest",
            new { code = viewmodel.RequestInfo.RequestCode, msg = Constants.Message.NOT_FINISHED_TASK });
     }
     return RedirectToAction("Index");
 }
 public ActionResult CancelRequestAssignIp(ProcessRequestAssignIPViewModel viewmodel)
 {
     var customer = GetCurrentUserName();
     var result = RequestBLO.Current.CancelRequestAssignIP(viewmodel.RequestInfo.RequestCode,
         customer, viewmodel.RequestInfo.TaskCode);
     //dang ky ham cho client
     Notify(result.NotificationCodes);
     return RedirectToAction("Detail", "Request", new
     { code = viewmodel.RequestInfo.RequestCode, msg = Constants.Message.CANCEL_REQUEST_ASSIGN_IP });
 }
 public ActionResult CancelRequestAssignIp(ProcessRequestAssignIPViewModel viewmodel)
 {
     var status = RequestBLO.Current.GetByKeys(new Request { RequestCode = viewmodel.RequestInfo.RequestCode }).StatusCode;
     if (status == Constants.StatusCode.REQUEST_REJECTED || status == Constants.StatusCode.REQUEST_DONE || status == Constants.StatusCode.REQUEST_CANCELLED)
     {
         return RedirectToAction("Detail", "Request", new
         {
             code = viewmodel.RequestInfo.RequestCode,
             msg = Constants.Message.ERROR_CANCEL_REQUEST
         });
     }
     else
     {
         var customer = GetCurrentUserName();
         var result = RequestBLO.Current.CancelRequestAssignIP(viewmodel.RequestInfo.RequestCode,
             customer, viewmodel.RequestInfo.TaskCode);
         //dang ky ham cho client
         Notify(result.NotificationCodes);
         return RedirectToAction("Detail", "Request", new
         { code = viewmodel.RequestInfo.RequestCode, msg = Constants.Message.CANCEL_REQUEST_ASSIGN_IP });
     }
 }