Esempio n. 1
0
        public ActionResult AddHardware(TeamAsset assetModel)
        {
            if (ModelState.IsValid)
            {
                TeamAsset  asset    = null;
                HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
                var        response = client.PostAsJsonAsync("api/asset/CreateAsset", assetModel).Result;
                if (response.IsSuccessStatusCode)
                {
                    var jsonData = response.Content.ReadAsStringAsync().Result;
                    if (!String.IsNullOrEmpty(jsonData))
                    {
                        asset = JsonConvert.DeserializeObject <TeamAsset>(jsonData);
                    }
                    return(RedirectToAction("HardwareContainer"));
                }
                else
                {
                    var jsonData = response.Content.ReadAsStringAsync().Result;
                    var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                    ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
                }
            }
            var _message = string.Join(Environment.NewLine, ModelState.Values
                                       .SelectMany(x => x.Errors)
                                       .Select(x => x.ErrorMessage));

            return(Json(new { success = false, message = _message }));
        }
        public async Task <ActionResult> RemoveItem(int id)
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var        response = await client.DeleteAsync("api/cart/Delete/" + id);

            return(RedirectToAction("CartItem", "Cart"));
        }
        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"));
        }
Esempio n. 4
0
        public async Task <User> GetUserData(ServiceType webApiType)
        {
            ErrorMessage = string.Empty;
            AccessToken token = null;

            switch (webApiType)
            {
            case ServiceType.CentralizeWebApi: token = LicenseSessionState.Instance.CentralizedToken; break;

            case ServiceType.OnPremiseWebApi: token = LicenseSessionState.Instance.OnPremiseToken; break;
            }
            HttpClient client   = WebApiServiceLogic.CreateClient(webApiType);
            var        response = await client.GetAsync("api/user/UserById/" + token.Id);

            if (response.IsSuccessStatusCode)
            {
                var userJson = response.Content.ReadAsStringAsync().Result;
                client.Dispose();
                var user = Newtonsoft.Json.JsonConvert.DeserializeObject <User>(userJson);
                return(user);
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ErrorMessage = response.ReasonPhrase + " - " + obj.Message;
            }
            return(null);
        }
Esempio n. 5
0
        public string UpdateLicense(int concurrentUserCount, string[] selectedSubscription)
        {
            List <string> teamIdList = new List <string>();

            teamIdList.Add(TempData["Teamid"].ToString());
            List <int>             listOfProId = ExtractLicenseData(selectedSubscription);
            TeamLicenseDataMapping mapping     = new TeamLicenseDataMapping()
            {
                ConcurrentUserCount = concurrentUserCount, ProductIdList = listOfProId, TeamList = teamIdList
            };
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.PostAsJsonAsync("api/License/CreateTeamLicence", mapping).Result;

            if (!response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                return(response.ReasonPhrase + " - " + obj.Message);
            }
            else
            {
                if (teamIdList.Contains(LicenseSessionState.Instance.SelectedTeam.Id.ToString()))//doubt
                {
                    var subscriptionDetails = OnPremiseSubscriptionLogic.GetUserLicenseForUser();
                    LicenseSessionState.Instance.UserSubscriptionList = subscriptionDetails;
                }
            }
            return(String.Empty);
        }
Esempio n. 6
0
        public ActionResult EditTeam(int id, Team model)
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.PutAsJsonAsync("api/team/Update/" + id, model).Result;

            if (response.IsSuccessStatusCode)
            {
                var data    = response.Content.ReadAsStringAsync().Result;
                var teamObj = JsonConvert.DeserializeObject <Team>(data);
                LicenseSessionState.Instance.TeamList.RemoveAll(f => f.Id == id);
                LicenseSessionState.Instance.TeamList.Add(teamObj);
                return(RedirectToAction("Index"));
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
            }
            var _message = string.Join(Environment.NewLine, ModelState.Values
                                       .SelectMany(x => x.Errors)
                                       .Select(x => x.ErrorMessage));

            return(Json(new { success = false, message = _message }));
        }
        public ActionResult LicenseApprovalByTeam(int teamId)
        {
            List <UserLicenseRequest> requestList = new List <UserLicenseRequest>();
            var adminId = string.Empty;

            if (LicenseSessionState.Instance.SelectedTeam != null)
            {
                adminId = LicenseSessionState.Instance.SelectedTeam.AdminId;
            }

            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.GetAsync("api/License/GetRequestedLicenseByTeam/" + teamId).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                if (!String.IsNullOrEmpty(jsonData))
                {
                    requestList = JsonConvert.DeserializeObject <List <UserLicenseRequest> >(jsonData);
                }
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
            }
            return(View(requestList));
        }
        public ActionResult UserConfiguration(int id, string userId, string actionType)
        {
            HttpClient          client = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            HttpResponseMessage response;
            TeamMember          mem = new TeamMember()
            {
                Id            = id,
                InviteeUserId = userId
            };

            switch (actionType)
            {
            case "Admin":
                mem.IsAdmin = true;
                response    = client.PutAsJsonAsync("api/TeamMember/UpdateAdminAccess", mem).Result;
                break;

            case "RemoveAdmin":
                mem.IsAdmin = false;
                response    = client.PutAsJsonAsync("api/TeamMember/UpdateAdminAccess", mem).Result;
                break;

            case "Remove":
                response = client.DeleteAsync("api/TeamMember/DeleteTeamMember/" + id).Result;
                break;
            }
            return(RedirectToAction("TeamContainer"));
        }
        private TeamDetails LoadTeamMember(int teamId)
        {
            TeamDetails model    = null;
            HttpClient  client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var         response = client.GetAsync("api/Team/GetById/" + teamId).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                model = JsonConvert.DeserializeObject <TeamDetails>(jsonData);
                var SelectedTeam = new Team();
                SelectedTeam.AdminId     = model.Team.AdminId;
                SelectedTeam.Id          = model.Team.Id;
                SelectedTeam.Name        = model.Team.Name;
                SelectedTeam.TeamMembers = model.AcceptedUsers;
                LicenseSessionState.Instance.SelectedTeam = SelectedTeam;
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
            }
            return(model);
        }
        public string RevokeLicenseFromUser(string[] SelectedSubscription)
        {
            List <string> userIdList = new List <string>();

            userIdList.Add(Convert.ToString(TempData["UserId"]));
            List <LicenseData> lstLicData = new List <LicenseData>();

            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];

                LicenseData licData = new LicenseData()
                {
                    UserSubscriptionId = Convert.ToInt32(subscriptionId),
                    ProductId          = Convert.ToInt32(prodId)
                };
                lstLicData.Add(licData);
            }
            UserLicenseDataMapping mapping = new UserLicenseDataMapping()
            {
                TeamId = LicenseSessionState.Instance.SelectedTeam.Id, LicenseDataList = lstLicData, UserList = userIdList
            };
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.PostAsJsonAsync("api/License/RevokeUserLicence", mapping).Result;

            if (!response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                return(response.ReasonPhrase + " - " + obj.Message);
            }
            return(String.Empty);
        }
        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"));
        }
Esempio n. 12
0
        public ActionResult Create()
        {
            SubscriptionType subType     = new SubscriptionType();
            List <Product>   productList = new List <Product>();
            HttpClient       client      = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var response = client.GetAsync("api/Product/All").Result;

            if (response.IsSuccessStatusCode)
            {
                var jsondata = response.Content.ReadAsStringAsync().Result;
                if (!String.IsNullOrEmpty(jsondata))
                {
                    productList = JsonConvert.DeserializeObject <List <Product> >(jsondata);
                }
                subType.Products = productList;
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
            }
            subType.ActivationMonth     = 1;
            TempData["ActivationMonth"] = LicenseSessionState.Instance.SubscriptionMonth;
            return(View(subType));
        }
Esempio n. 13
0
        public async Task <ActionResult> Index()
        {
            TempData["CartCount"] = "";
            List <SubscriptionType> typeList = new List <SubscriptionType>();
            HttpClient          client       = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            HttpResponseMessage response;

            if (LicenseSessionState.Instance.IsGlobalAdmin)
            {
                response = await client.GetAsync("api/subscription/All");
            }
            else
            {
                response = await client.GetAsync("api/subscription/All/" + LicenseSessionState.Instance.User.ServerUserId);
            }
            if (response.IsSuccessStatusCode)
            {
                var data = response.Content.ReadAsStringAsync().Result;
                typeList = JsonConvert.DeserializeObject <List <SubscriptionType> >(data);
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
            }
            client.Dispose();
            CartItemCount();
            client.Dispose();
            return(View(typeList));
        }
Esempio n. 14
0
        public ActionResult CreateTeam(Team model)
        {
            if (ModelState.IsValid)
            {
                model.AdminId = LicenseSessionState.Instance.User.UserId;
                HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
                var        response = client.PostAsJsonAsync("api/Team/Create", model).Result;
                if (response.IsSuccessStatusCode)
                {
                    var jsonData = response.Content.ReadAsStringAsync().Result;
                    var data     = JsonConvert.DeserializeObject <Team>(jsonData);
                    LicenseSessionState.Instance.TeamList.Add(data);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var jsonData = response.Content.ReadAsStringAsync().Result;
                    var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                    ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
                }
            }
            var _message = string.Join(Environment.NewLine, ModelState.Values
                                       .SelectMany(x => x.Errors)
                                       .Select(x => x.ErrorMessage));

            return(Json(new { success = false, message = _message }));
        }
Esempio n. 15
0
        public void SyncRenewData()
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var        response = client.PostAsJsonAsync("api/UserSubscription/RenewSubscription/" + LicenseSessionState.Instance.User.ServerUserId, TempData["RenewSubscription"]).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
            }
        }
        public ActionResult Invite(int teamId, UserInviteModel model)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                TeamMember invite = new TeamMember();
                invite.InvitationDate = DateTime.Now.Date;
                invite.InviteeEmail   = model.Email;
                invite.TeamId         = LicenseSessionState.Instance.SelectedTeam.Id;
                invite.InviteeStatus  = InviteStatus.Pending.ToString();

                HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
                var        response = client.PostAsJsonAsync("api/TeamMember/CreateInvite", invite).Result;
                if (response.IsSuccessStatusCode)
                {
                    var jsonData = response.Content.ReadAsStringAsync().Result;
                    if (!String.IsNullOrEmpty(jsonData))
                    {
                        var    teamMemResObj = JsonConvert.DeserializeObject <TeamMemberResponse>(jsonData);
                        string body          = System.IO.File.ReadAllText(Server.MapPath("~/EmailTemplate/Invitation.htm"));
                        body = body.Replace("{{AdminEmail}}", LicenseSessionState.Instance.User.Email);
                        string encryptString = invite.TeamId + "," + teamMemResObj.TeamMemberId;
                        string passPhrase    = System.Configuration.ConfigurationManager.AppSettings.Get("passPhrase");
                        var    dataencrypted = EncryptDecrypt.EncryptString(encryptString, passPhrase);

                        string joinUrl = Url.Action("Confirm", "Account",
                                                    new { invite = dataencrypted, status = InviteStatus.Accepted.ToString() }, protocol: Request.Url.Scheme);
                        string declineUrl = Url.Action("Confirm", "Account",
                                                       new { invite = dataencrypted, status = InviteStatus.Declined.ToString() }, protocol: Request.Url.Scheme);

                        body = body.Replace("{{JoinUrl}}", joinUrl);
                        body = body.Replace("{{DeclineUrl}}", declineUrl);
                        body = body.Replace("{{UserName}}", teamMemResObj.UserName);
                        body = body.Replace("{{Password}}", teamMemResObj.Password);
                        EmailService service = new EmailService();
                        service.SendEmail(model.Email, "Invite to fluke Calibration", body);

                        return(RedirectToAction("TeamContainer"));
                    }
                }
                else
                {
                    var jsonData = response.Content.ReadAsStringAsync().Result;
                    var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                    ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
                }
            }
            var _message = string.Join(Environment.NewLine, ModelState.Values
                                       .SelectMany(x => x.Errors)
                                       .Select(x => x.ErrorMessage));

            return(Json(new { success = false, message = _message }));
        }
Esempio n. 17
0
        public ActionResult Features(int id)
        {
            List <Feature> featureList = new List <Feature>();
            HttpClient     client      = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var            response    = client.GetAsync("api/feature/GetByCategory/" + id).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                featureList = JsonConvert.DeserializeObject <List <Feature> >(jsonData);
            }
            return(View(featureList));
        }
Esempio n. 18
0
        // GET: Feature
        public ActionResult Index()
        {
            List <Feature> data    = null;
            HttpClient     client  = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var            respons = client.GetAsync("api/Feature/All").Result;

            if (respons.IsSuccessStatusCode)
            {
                var jsonData = respons.Content.ReadAsStringAsync().Result;
                data = JsonConvert.DeserializeObject <List <Feature> >(jsonData);
            }
            return(View(data));
        }
Esempio n. 19
0
        public ActionResult CMMSProducts()
        {
            List <Product> cmmsProducts = new List <Product>();
            HttpClient     client       = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var            response     = client.GetAsync("api/Product/GetCMMSProducts").Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                cmmsProducts = JsonConvert.DeserializeObject <List <Product> >(jsonData);
            }
            return(View(cmmsProducts));
        }
        public ConcurrentUserLogin IsConcurrentUserLoggedIn()
        {
            ConcurrentUserLogin userLogin = new ConcurrentUserLogin();

            userLogin.TeamId = LicenseSessionState.Instance.SelectedTeam.Id;
            userLogin.UserId = LicenseSessionState.Instance.User.UserId;
            HttpClient client       = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response     = client.PostAsJsonAsync("api/User/IsConcurrentUserLoggedIn", userLogin).Result;
            var        jsonData     = response.Content.ReadAsStringAsync().Result;
            var        userLoginObj = JsonConvert.DeserializeObject <ConcurrentUserLogin>(jsonData);

            return(userLoginObj);
        }
Esempio n. 21
0
        public ActionResult Delete(int id)
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var        response = client.DeleteAsync("api/productCategory/Delete/" + id).Result;

            if (!response.IsSuccessStatusCode)
            {
                var data            = response.Content.ReadAsStringAsync().Result;
                var responseFailure = JsonConvert.DeserializeObject <ResponseFailure>(data);
                return(Json(new { message = responseFailure.Message, success = false }));
            }
            return(Json(new { message = "success", success = true }));
        }
Esempio n. 22
0
        public ActionResult Delete(int Id)
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var        response = client.DeleteAsync("api/Feature/Delete/" + Id).Result;

            if (response.IsSuccessStatusCode)
            {
                return(Json(new { message = "success", success = true }));
            }
            else
            {
                var jsonData  = response.Content.ReadAsStringAsync().Result;
                var errorData = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                return(Json(new { message = errorData.Message, success = false }));
            }
        }
Esempio n. 23
0
        public ActionResult Edit(int id)
        {
            ProductCategory category = null;
            HttpClient      client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var             response = client.GetAsync("api/productCategory/GetById/" + id).Result;

            if (response.IsSuccessStatusCode)
            {
                var data = response.Content.ReadAsStringAsync().Result;
                category = JsonConvert.DeserializeObject <ProductCategory>(data);
            }
            else
            {
                category = new ProductCategory();
            }
            return(View(category));
        }
Esempio n. 24
0
        // GET: ProductCategory
        public ActionResult Index()
        {
            List <ProductCategory> categories = new List <ProductCategory>();
            HttpClient             client     = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var response = client.GetAsync("api/ProductCategory/All").Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                categories = JsonConvert.DeserializeObject <List <ProductCategory> >(jsonData);
            }
            else
            {
                categories = new List <ProductCategory>();
            }
            return(View(categories));
        }
Esempio n. 25
0
        public async Task <bool> UpdateProfile(User model, ServiceType type, string userId)
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(type);
            var        response = await client.PutAsJsonAsync("/api/user/update/" + userId, model);

            if (response.IsSuccessStatusCode)
            {
                return(true);
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ErrorMessage = response.ReasonPhrase + " - " + obj.Message;
            }
            return(false);
        }
        public void GetFeatureList()
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var        response = client.GetAsync("api/Product/ProductDependency").Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                ProductDependency dependencyObj = JsonConvert.DeserializeObject <ProductDependency>(jsonData);
                ViewBag.Categories = dependencyObj.Categories;
                ViewBag.Features   = dependencyObj.Features;
            }
            else
            {
                ViewBag.Categories = new List <ProductCategory>();
                ViewBag.Features   = new List <Feature>();
            }
        }
Esempio n. 27
0
        public ActionResult RevokeTeamLicense(int teamId, params string[] SelectedSubscription)
        {
            DeleteTeamDetails details = new DeleteTeamDetails();

            details.LogInUserId   = LicenseSessionState.Instance.User.UserId;
            details.TeamId        = teamId;
            details.productIdList = ExtractLicenseData(SelectedSubscription);
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.PostAsJsonAsync("api/License/Delete", details).Result;

            if (!response.IsSuccessStatusCode)
            {
                var jsondata        = response.Content.ReadAsStringAsync().Result;
                var responsefailure = JsonConvert.DeserializeObject <ResponseFailure>(jsondata);
                return(Json(new { success = false, message = responsefailure.Message }));
            }
            return(Json(new { success = true, message = "" }));
        }
        public ActionResult Edit(int id, Product productDetails, string[] rboCategory, string[] featuresList)
        {
            if (ModelState.IsValid)
            {
                if (rboCategory.Count() > 0)
                {
                    productDetails.Categories = new List <ProductCategory>();
                    foreach (var categoryId in rboCategory)
                    {
                        productDetails.Categories.Add(new ProductCategory()
                        {
                            Id = Convert.ToInt32(categoryId)
                        });
                    }
                }

                if (featuresList.Count() > 0)
                {
                    productDetails.AssociatedFeatures = new List <Feature>();
                    foreach (var featureId in featuresList)
                    {
                        productDetails.AssociatedFeatures.Add(new Feature()
                        {
                            Id = Convert.ToInt32(featureId)
                        });
                    }
                }
                productDetails.ModifiedDate = DateTime.Now;
                HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
                var        response = client.PutAsJsonAsync("api/product/update/" + id, productDetails).Result;
                if (response.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var jsondata      = response.Content.ReadAsStringAsync().Result;
                    var errorResponse = JsonConvert.DeserializeObject <ResponseFailure>(jsondata);
                    ModelState.AddModelError("", errorResponse.Message);
                }
            }
            GetFeatureList();
            return(View(productDetails));
        }
        public async Task <ActionResult> OrderStatus()
        {
            List <PurchaseOrder> poList = new List <PurchaseOrder>();
            HttpClient           client = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var response = await client.GetAsync("api/purchaseorder/OrderByUser/" + LicenseSessionState.Instance.User.ServerUserId);

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                poList = JsonConvert.DeserializeObject <List <PurchaseOrder> >(jsonData);
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
            }
            return(View(poList));
        }
        public async Task <ActionResult> OrderDetail(int id)
        {
            PurchaseOrder order    = new PurchaseOrder();
            HttpClient    client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var           response = await client.GetAsync("api/purchaseorder/OrderById/" + id.ToString());

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