Example #1
0
        /// <summary>
        /// Creating the single object  to DB
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        private bool CreateRequest(UserLicenseRequest req)
        {
            var obj = AutoMapper.Mapper.Map <Core.Model.UserLicenseRequest>(req);

            obj = Work.UserLicenseRequestRepo.Create(obj);
            return(obj.Id > 0);
        }
        public ActionResult LicenseApprovalByTeam(string comment, string status, params string[] selectLicenseRequest)
        {
            List <UserLicenseRequest> licReqList = new List <UserLicenseRequest>();

            foreach (var id in selectLicenseRequest)
            {
                UserLicenseRequest userlicReq = new UserLicenseRequest();
                userlicReq.Id = Convert.ToInt32(id);
                switch (status)
                {
                case "Approve": userlicReq.IsApproved = true; break;

                case "Reject": userlicReq.IsRejected = true; break;
                }
                userlicReq.Comment    = comment;
                userlicReq.ApprovedBy = LicenseSessionState.Instance.User.UserName;
                licReqList.Add(userlicReq);
            }

            if (licReqList.Count > 0)
            {
                HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
                var        response = client.PostAsJsonAsync("api/license/ApproveRejectLicense", licReqList).Result;
                if (!response.IsSuccessStatusCode)
                {
                    var jsonData = response.Content.ReadAsStringAsync().Result;
                    var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                    ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
                    GetTeamList();
                    return(View());
                }
            }
            return(RedirectToAction("TeamContainer", "TeamManagement"));
        }
        public ActionResult LicenseRequest(params string[] SelectedSubscription)
        {
            List <UserLicenseRequest> licReqList = new List <UserLicenseRequest>();

            foreach (var data in SelectedSubscription)
            {
                var splitValue     = data.Split(new char[] { '-' });
                var prodId         = splitValue[0].Split(new char[] { ':' })[1];
                var subscriptionId = splitValue[1].Split(new char[] { ':' })[1];

                UserLicenseRequest req = new UserLicenseRequest()
                {
                    Requested_UserId   = LicenseSessionState.Instance.User.UserId,
                    ProductId          = Convert.ToInt32(prodId),
                    UserSubscriptionId = Convert.ToInt32(subscriptionId),
                    RequestedDate      = DateTime.Now.Date,
                    TeamId             = LicenseSessionState.Instance.SelectedTeam.Id
                };
                licReqList.Add(req);
            }

            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.PostAsJsonAsync("api/License/RequestLicense", licReqList).Result;

            if (!response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);

                return(View());
            }
            return(RedirectToAction("TeamContainer", "TeamManagement"));
        }
Example #4
0
        /// <summary>
        /// Updating the single object  to DB
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        private bool UpdateRequest(UserLicenseRequest req)
        {
            var obj = Work.UserLicenseRequestRepo.GetById(req.Id);

            obj.IsApproved = req.IsApproved;
            obj.IsRejected = req.IsRejected;
            obj.ApprovedBy = req.ApprovedBy;
            obj.Comment    = req.Comment;
            obj            = Work.UserLicenseRequestRepo.Update(obj);
            Work.UserLicenseRequestRepo.Save();
            return(obj != null);
        }
        public void UpdateUserLicenseRequest()
        {
            UserLicenseRequest req = new UserLicenseRequest();
            User teamMember        = userLogic.GetUserByEmail("*****@*****.**");
            var  data = reqLogic.GetLicenseRequest(teamMember.UserId);

            if (data.Count > 0)
            {
                var dt = data[0];
                dt.IsApproved = true;
                dt.ApprovedBy = "*****@*****.**";
                List <UserLicenseRequest> reqList = new List <UserLicenseRequest>();
                reqList.Add(dt);
                UserLicenseRequestLogic reqLogic = new UserLicenseRequestLogic();
                reqLogic.Update(reqList);
            }
            else
            {
                Assert.Fail("No License Request Exist");
            }
        }
        public void CreateUserLicenseRequest()
        {
            UserLicenseRequest req = new UserLicenseRequest();
            User adminUser         = userLogic.GetUserByEmail("*****@*****.**");
            User teamMember        = userLogic.GetUserByEmail("*****@*****.**");
            var  subList           = useSubLogic.GetSubscription(adminUser.UserId);

            if (subList.Count > 0)
            {
                req.Requested_UserId   = teamMember.UserId;
                req.UserSubscriptionId = subList[0].Id;
                req.ProductId          = 1;
                req.RequestedDate      = DateTime.Now;
                List <UserLicenseRequest> reqList = new List <UserLicenseRequest>();
                reqList.Add(req);
                UserLicenseRequestLogic reqLogic = new UserLicenseRequestLogic();
                reqLogic.Create(reqList);
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("No Subscriptions are purechased");
            }
        }