Exemplo n.º 1
0
        /// <summary>
        /// Get the list of EndUser based on companyId and customerId
        /// </summary>
        /// <param name="param"></param>
        /// <param name="companyId">company Id</param>
        /// <param name="customerId">customer Id</param>
        /// <returns>End User List</returns>
        public ActionResult EndUserList(MODEL.jQueryDataTableParamModel param, int companyId, int customerId)
        {
            try
            {
                EndUserService       enduserService = new EndUserService();
                List <MODEL.EndUser> enduserList    = new List <EndUser>();

                List <EndUserVO> enduserVOlist = enduserService.GetEndUserListByCompanyIdandCustomerId(companyId, customerId);

                foreach (var item in enduserVOlist)
                {
                    enduserList.Add(new MODEL.EndUser(item));
                }

                //get the field on with sorting needs to happen and set the
                //ordering function/delegate accordingly.
                int sortColumnIndex  = Convert.ToInt32(Request["iSortCol_0"]);
                var orderingFunction = GetEndUserOrderingFunction(sortColumnIndex);

                var result = GetFilteredObjects(param, enduserList, orderingFunction);
                return(result);
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
        /// <summary>
        /// Gets a list of end users filtered based on selected company and invoice customer
        /// </summary>
        /// <param name="companyId">The company Id</param>
        /// <param name="invoiceCustomerId">The invoice customer Id</param>
        /// <returns>The List of End Users</returns>
        private List <MODEL.EndUser> GetEndUserList(int companyId, int invoiceCustomerId = 0)
        {
            MODEL.Contract contract = new MODEL.Contract();

            //Get all end users associated with the company
            EndUserService   endUserService = new EndUserService();
            List <EndUserVO> endUserVOList  = endUserService.GetEndUserList(companyId, invoiceCustomerId).OrderBy(c => c.Name).ToList();

            foreach (var item in endUserVOList)
            {
                contract.EndUserList.Add(new MODEL.EndUser(item));
            }

            return(contract.EndUserList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Delete the EndUser(s)
        /// </summary>
        /// <param name="Ids">Ids of endusers to be deleted</param>
        public ActionResult EndUserDelete(List <int> ids)
        {
            try
            {
                //Get user id
                int?userId = Session.GetUserId();

                EndUserService enduserService = new EndUserService();
                enduserService.DeleteEndUser(ids, userId);
                return(new HttpStatusCodeResult(200));
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Save the end user
 /// </summary>
 /// <param name="model">The EndUser model</param>
 public ActionResult EndUserSave(MODEL.EndUser model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             //Get user id
             int?           userId         = Session.GetUserId();
             EndUserService endUserService = new EndUserService();
             EndUserVO      endUserVO      = model.Transpose(userId);
             endUserService.SaveEndUser(endUserVO);
             return(new HttpStatusCodeResult(200));
         }
         else
         {
             throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.ENDUSER));
         }
     }
     catch (ApplicationException e)
     {
         return(new HttpStatusCodeAndErrorResult(500, e.Message));
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Edit end user
        /// </summary>
        /// <param name="id">The end user Id</param>
        /// <returns>The enduser details view</returns>
        public ActionResult EndUserEdit(int id)
        {
            MODEL.EndUser enduser = new EndUser();
            try
            {
                EndUserService enduserService = new EndUserService();

                //Get EndUser details
                EndUserVO enduserVO = enduserService.GetEndUserById(id);
                if (enduserVO == null)
                {
                    ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.ENDUSER));
                }
                else
                {
                    enduser = new EndUser(enduserVO);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(PartialView("EndUserDetails", enduser));
        }