Exemplo n.º 1
0
        public async Task <IResultServiceModel <bool> > UserIsOnlyCustomer(User user)
        {
            IResultServiceModel <bool> rm = new ResultServiceModel <bool>();

            try
            {
                var roleCustomer = await this.roleManager.FindByNameAsync(RoleDefinitions.Customer);

                if (roleCustomer != null)
                {
                    if (user.Roles.Where(w => w.RoleId != roleCustomer.Id).Any())
                    {
                        rm.OnSuccess(false);
                    }
                    else
                    {
                        rm.OnSuccess(true);
                    }
                }
                else
                {
                    rm.OnError();
                }
            }
            catch (Exception ex)
            {
                rm.OnException(ex);
            }

            return(rm);
        }
Exemplo n.º 2
0
        public IResultServiceModel <File> FindGSByIdAndProject(long id, long projectId)
        {
            IResultServiceModel <File> rsm = new ResultServiceModel <File>();

            try
            {
                var item = this.context
                           .Files
                           .Where(w => w.Id == id && w.Customer.ProjectId == projectId)
                           .FirstOrDefault();

                if (item != null)
                {
                    rsm.OnSuccess(item);
                }
                else
                {
                    rsm.OnError(ErrorResources.ItemDoesNotExist, EnumErrorCode.ITEM_DOES_NOT_EXIST);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 3
0
        public IResultServiceModel <Customer> FindByIdAndProject(long customerId, long projectId)
        {
            IResultServiceModel <Customer> rsm = new ResultServiceModel <Customer>();

            try
            {
                var cuz = this.context
                          .Customers
                          .Where(w => w.Id == customerId && w.ProjectId == projectId)
                          .SingleOrDefault();

                if (cuz != null)
                {
                    rsm.OnSuccess(cuz);
                }
                else
                {
                    rsm.OnError(ErrorResources.ItemDoesNotExist, EnumErrorCode.ITEM_DOES_NOT_EXIST);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }
            return(rsm);
        }
Exemplo n.º 4
0
        public IResultServiceModel <long> GetMostRecent()
        {
            IResultServiceModel <long> rsm = new ResultServiceModel <long>();

            try
            {
                var item = this.context
                           .Projects
                           .OrderByDescending(o => o.Id)
                           .FirstOrDefault();

                if (item != null)
                {
                    rsm.OnSuccess(item.Id);
                }
                else
                {
                    rsm.OnError(ErrorResources.NoProjectsAlreadyCreated, EnumErrorCode.ZERO_PROJECTS);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 5
0
        public IResultServiceModel <Customer> GetById(long id)
        {
            IResultServiceModel <Customer> rsm = new ResultServiceModel <Customer>();

            try
            {
                var item = this.context
                           .Customers
                           .Where(w => w.Id == id)
                           .FirstOrDefault();

                if (item != null)
                {
                    rsm.OnSuccess(item);
                }
                else
                {
                    rsm.OnError(CustomerResources.CustomerNotFoundForAnyActiveProject, EnumErrorCode.CUSTOMER_USER_NOT_FOUND_FOR_ANY_PROJECT);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 6
0
        public IResultServiceModel <WFTransition> FindByWorkflowAndEndPointStates(long originWFStateId, long destinationWFStateId, long wfWorkflowId, long wfWorkflowVersion)
        {
            IResultServiceModel <WFTransition> rsm = new ResultServiceModel <WFTransition>();

            try
            {
                var tr = this.context
                         .WFWorkflowTransitions
                         .Where(w => w.WFWorkflowId == wfWorkflowId &&
                                w.WFWorkflowVersion == wfWorkflowVersion &&
                                w.WFWorkflowStateOrigin.WFStateId == originWFStateId &&
                                w.WFWorkflowStateDestination.WFStateId == destinationWFStateId)
                         .FirstOrDefault();

                if (tr != null)
                {
                    rsm.OnSuccess(tr.WFTransition);
                }
                else
                {
                    rsm.OnError(ErrorResources.ItemDoesNotExist, EnumErrorCode.TRANSITION_NOT_FOUND);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 7
0
        public async Task <HttpResponseMessage> RegisterReservation(CustomerRegistrationRequest request)
        {
            HttpResponseMessage httpResponse = null;
            Customer            cuz          = null;
            string uri         = string.Empty;
            var    rmsCustomer = await this.mainService.RegisterNewCustomerInProjectAsync(request, false);

            IResultServiceModel <CustomerRegistrationResponse> response = new ResultServiceModel <CustomerRegistrationResponse>();

            if (rmsCustomer.Success)
            {
                cuz = rmsCustomer.Value;
                this.mainService.SendEmailNewCustomerSignUp(cuz, this.GetBaseUrl());

                response.OnSuccess(new CustomerRegistrationResponse()
                {
                    CustomerId = cuz.Id, ProjectId = rmsCustomer.Value.ProjectId
                });
            }
            else
            {
                response.OnError(rmsCustomer.ErrorMessage, rmsCustomer.ErrorCode);
            }

            httpResponse = Request.CreateResponse <IResultServiceModel <CustomerRegistrationResponse> >(HttpStatusCode.Created, response);
            uri          = Url.Link("RegisterReservationApi", new { id = response.ErrorCode });

            httpResponse.Headers.Location = new Uri(uri);

            return(httpResponse);
        }
Exemplo n.º 8
0
        public IResultServiceModel <WFWorkflow> GetById(long id)
        {
            IResultServiceModel <WFWorkflow> rsm = new ResultServiceModel <WFWorkflow>();

            try
            {
                var item = this.context
                           .WFWorkflows
                           .Where(w => w.Id == id)
                           .FirstOrDefault();

                if (item != null)
                {
                    rsm.OnSuccess(item);
                }
                else
                {
                    rsm.OnError(ErrorResources.ItemDoesNotExist, EnumErrorCode.ITEM_DOES_NOT_EXIST);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 9
0
        public IResultServiceModel <Project> FindByIdAndUser(long projectId, User user)
        {
            IResultServiceModel <Project> rm = new ResultServiceModel <Project>();

            try
            {
                var isAuthorized = this.context
                                   .UserProjects
                                   .Where(w => w.UserId == user.Id &&
                                          w.ProjectId == projectId)
                                   .Any();

                if (isAuthorized)
                {
                    var prj = this.context.Projects.Find(projectId);
                    rm.OnSuccess(prj);
                }
                else
                {
                    rm.OnError(ProjectResources.UserHasNotEnoughPrivilegesOnThisProjectForThisAction, EnumErrorCode.INSUFFICIENT_PRIVILEGES);
                }
            }
            catch (Exception ex)
            {
                rm.OnException(ex);
            }


            return(rm);
        }
Exemplo n.º 10
0
        public IResultServiceModel <long> CheckDownloadExcelFileId(string guid)
        {
            IResultServiceModel <long> rm = new ResultServiceModel <long>();

            var rsm = this.miscRepository.GetByKeyWithValue(MiscKeyEnum.EXCEL_DOWNLOAD_GUID.ToString(), guid);

            if (rsm.Success)
            {
                if (rsm.Value.Limit > DateTime.Now)
                {
                    var info = Newtonsoft.Json.JsonConvert.DeserializeObject <ProjectExcelFileInfo>(rsm.Value.Value);

                    rm.OnSuccess(info.ProjectId);
                }
                else
                {
                    rm.OnError(MiscResources.TimeForDownloadThisExcelFileIsOut);
                }
            }
            else
            {
                rm.OnError(rm.ErrorMessage, rm.ErrorCode);
            }

            return(rm);
        }
Exemplo n.º 11
0
        public IResultServiceModel <long> GetWorkflowIdByCode(string code)
        {
            IResultServiceModel <long> rsm = new ResultServiceModel <long>();

            try
            {
                long?id = this.context
                          .WFWorkflows
                          .Where(w => w.Code == code)
                          .Select(s => s.Id)
                          .SingleOrDefault();

                if (id.HasValue)
                {
                    rsm.OnSuccess(id.Value);
                }
                else
                {
                    rsm.OnError(ErrorResources.ItemDoesNotExist, EnumErrorCode.ITEM_DOES_NOT_EXIST);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 12
0
        public IResultServiceModel <WFFileState> GetById(long id)
        {
            IResultServiceModel <WFFileState> rsm = new ResultServiceModel <WFFileState>();

            var item = this.context
                       .WFFileStates
                       .Include(i => i.WFState)
                       .Include(i => i.User)
                       .Where(w => w.Id == id)
                       .FirstOrDefault();

            if (item != null)
            {
                if (item.WFState == null)
                {
                    item.WFState = this.context.WFStates.Find(item.WFStateId);
                }
                rsm.OnSuccess(item);
            }
            else
            {
                rsm.OnError(ErrorResources.ItemDoesNotExist);
            }

            return(rsm);
        }
Exemplo n.º 13
0
        public async Task <HttpResponseMessage> PostItem([FromBody] ProjectItemRequest request)
        {
            HttpResponseMessage httpResponse = null;
            string uri    = Url.Link("ProjectPostApi", new { id = request.id });
            string userId = request.userName;
            IResultServiceModel <ProjectItemResponse> response = new ResultServiceModel <ProjectItemResponse>();

            if (!ModelState.IsValid)
            {
                response.OnError(this.GetErrorsFromModelState(), EnumErrorCode.VALIDATION_ERROR);
            }
            else
            {
                try
                {
                    var rmCred = this.ValidateUserCredentials(request.userName);
                    if (rmCred.Success)
                    {
                        IResultServiceModel <Project> rmsItem;

                        if (request.id == 0)
                        {
                            rmsItem = await this.projectService.AddProjectByUserAsync(request);
                        }
                        else
                        {
                            rmsItem = await this.projectService.EditProjectByUserAsync(request);
                        }

                        if (rmsItem.Success)
                        {
                            response.OnSuccess(new ProjectItemResponse()
                            {
                                item = new ProjectPOCO(rmsItem.Value)
                            });
                        }
                        else
                        {
                            response.OnError(
                                ErrorResources.ModelStateErrors_Format.sf(rmsItem.ErrorMessage),
                                rmsItem.ErrorCode
                                );
                        }
                    }
                    else
                    {
                        response.OnError(rmCred.ErrorMessage, rmCred.ErrorCode);
                    }
                }
                catch (Exception ex)
                {
                    response.OnException(ex);
                }
            }

            httpResponse = Request.CreateResponse <IResultServiceModel <ProjectItemResponse> >(HttpStatusCode.Created, response);
            httpResponse.Headers.Location = new Uri(uri);

            return(httpResponse);
        }
Exemplo n.º 14
0
        public IResultServiceModel <WFState> GetStateByWorkflowAndCode(long wfWorkflowId, long wfWorkflowVersion, string movementCode)
        {
            IResultServiceModel <WFState> rsm = new ResultServiceModel <WFState>();

            try
            {
                movementCode = movementCode.ToUpper();

                var wfState = this.context
                              .WFWorkflowStates
                              .Where(w => w.WFWorkflowId == wfWorkflowId &&
                                     w.WFWorkflowVersion == wfWorkflowVersion &&
                                     w.WFState.Code == movementCode)
                              .Select(s => s.WFState)
                              .FirstOrDefault();

                if (wfState != null)
                {
                    rsm.OnSuccess(wfState);
                }
                else
                {
                    rsm.OnError(ErrorResources.WFStateNotFound, EnumErrorCode.STATE_NOT_FOUND);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }
            return(rsm);
        }
Exemplo n.º 15
0
        public IResultServiceModel <Customer> GetGeneralSpaceCustomerByProject(long projectId)
        {
            IResultServiceModel <Customer> rsm = new ResultServiceModel <Customer>();

            try
            {
                Customer item = this.context
                                .Customers
                                .Where(w => w.ProjectId == projectId && w.SpaceNumber == 0)
                                .FirstOrDefault();

                if (item != null)
                {
                    rsm.OnSuccess(item);
                }
                else
                {
                    rsm.OnError(ErrorResources.ItemDoesNotExist, EnumErrorCode.ITEM_DOES_NOT_EXIST);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 16
0
        public IResultServiceModel <WFState> GetSpecificStateByCode(string wfCode, string wfStateCode)
        {
            IResultServiceModel <WFState> rsm = new ResultServiceModel <WFState>();

            try
            {
                var item = this.context
                           .WFWorkflowStates
                           .Where(w => w.WFWorkflow.Code == wfCode &&
                                  w.WFState.Code == wfStateCode &&
                                  !w.IsInitial)
                           .FirstOrDefault();

                if (item != null)
                {
                    rsm.OnSuccess(item.WFState);
                }
                else
                {
                    rsm.OnError(ErrorResources.ItemDoesNotExist, EnumErrorCode.ITEM_DOES_NOT_EXIST);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 17
0
        public IResultServiceModel <IEnumerable <WFFileState> > GetListByFileId(long id)
        {
            IResultServiceModel <IEnumerable <WFFileState> > rsm = new ResultServiceModel <IEnumerable <WFFileState> >();

            try
            {
                var list = this.context
                           .WFFileStates
                           .Where(w => w.EntityId == id)
                           .OrderByDescending(o => o.TS)
                           .ToList();

                if (list != null)
                {
                    rsm.OnSuccess(list);
                }
                else
                {
                    rsm.OnError(HistoryResources.NoHistoryFound);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 18
0
        public IResultServiceModel <AppConfiguration> GetValue(string key)
        {
            IResultServiceModel <AppConfiguration> rsm = new ResultServiceModel <AppConfiguration>();

            try
            {
                var item = this.context
                           .AppConfigurations
                           .Where(w => w.Key == key)
                           .FirstOrDefault();

                if (item != null)
                {
                    rsm.OnSuccess(item);
                }
                else
                {
                    rsm.OnError(ErrorResources.ItemDoesNotExist, EnumErrorCode.ITEM_DOES_NOT_EXIST);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 19
0
        public async Task <HttpResponseMessage> Get()
        {
            HttpResponseMessage httpResponse = null;
            string uri = string.Empty;
            IResultServiceModel <AlfredDefaultPlatformParametersResponse>         response     = new ResultServiceModel <AlfredDefaultPlatformParametersResponse>();
            Task <IResultServiceModel <AlfredDefaultPlatformParametersResponse> > taskResponse = null;

            try
            {
                taskResponse = this.mainService.GetDefaultPlatformParametersAsync();
            }
            catch (Exception ex)
            {
                response.OnException(ex);
            }

            uri = Url.Link("AlfredGetApi", new { id = 0 });

            if (taskResponse != null)
            {
                response = await taskResponse;
            }
            else
            {
                response.OnSuccess(new AlfredDefaultPlatformParametersResponse()
                {
                    publicKey = "", totalStands = 1
                });
            }

            httpResponse = Request.CreateResponse <IResultServiceModel <AlfredDefaultPlatformParametersResponse> >(HttpStatusCode.Created, response);
            httpResponse.Headers.Location = new Uri(uri);

            return(httpResponse);
        }
Exemplo n.º 20
0
        public async Task <HttpResponseMessage> GSActivity([FromUri] ProjectGSpaceActivityRequest request)
        {
            HttpResponseMessage httpResponse = null;
            string uri    = Url.Link("ProjectGSActivityApi", new { userName = request.userName });;
            string userId = request.userName;
            IResultServiceModel <ProjectGSpaceActivityResponse> response = new ResultServiceModel <ProjectGSpaceActivityResponse>();

            try
            {
                var rmCred = this.ValidateUserCredentials(request.userName);
                if (rmCred.Success)
                {
                    var rsmCuz = this.mainService.GetCustomerForProjectGeneralSpace(request.pId, request.userName);
                    var cuz    = new CustomerPOCO(rsmCuz.Value);
                    response.OnSuccess(new ProjectGSpaceActivityResponse()
                    {
                        list = cuz.Files
                    });
                }
                else
                {
                    response.OnError(rmCred.ErrorMessage, rmCred.ErrorCode);
                }
            }
            catch (Exception ex)
            {
                response.OnException(ex);
            }

            httpResponse = Request.CreateResponse <IResultServiceModel <ProjectGSpaceActivityResponse> >(HttpStatusCode.Created, response);
            httpResponse.Headers.Location = new Uri(uri);

            return(httpResponse);
        }
Exemplo n.º 21
0
        public async Task <IResultServiceModel <Project> > AddProjectByUserAsync(ProjectItemRequest model)
        {
            IResultServiceModel <Project> rsm = new ResultServiceModel <Project>();

            //get the user
            User   user      = null;
            string roleFlags = string.Empty;

            try
            {
                user = await this.accountService.FindUserByUserNameOrEmailAsync(model.userName);

                /* 1st => data validation */
                var rm = this.CheckProjectForAdding(model);
                if (rm.Success)
                {
                    var project = new Project();
                    model.CopyTo(project);

                    this.projectRepository.Add(project);
                    var rmAdd = this.projectRepository.Save();

                    if (rmAdd.Success)
                    {
                        rmAdd = this.CompleteProjectCreation(project, model.userName);
                        if (rmAdd.Success)
                        {
                            rmAdd = this.GrantUsersInProject(project, user);

                            if (rmAdd.Success)
                            {
                                rsm.OnSuccess(project);
                            }
                            else
                            {
                                rsm.OnError(rmAdd.ErrorMessage, rmAdd.ErrorCode);
                            }
                        }
                        else
                        {
                            rsm.OnError(rmAdd.ErrorMessage, rmAdd.ErrorCode);
                        }
                    }
                    else
                    {
                        rsm.OnError(rmAdd.ErrorMessage, rmAdd.ErrorCode);
                    }
                }
                else
                {
                    rsm.OnError(rm.ErrorMessage, rm.ErrorCode);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 22
0
        public async Task <HttpResponseMessage> DeleteItem([FromUri] ProjectItemRequest request)
        {
            HttpResponseMessage httpResponse = null;
            string uri    = Url.Link("ProjectDeleteApi", new { id = request.id });
            string userId = request.userName;
            IResultServiceModel <ProjectItemResponse> response = new ResultServiceModel <ProjectItemResponse>();

            if (request.id <= 0)
            {
                response.OnError(ProjectResources.ErrorItemDoesNotExist_OnDelete, EnumErrorCode.ITEM_DOES_NOT_EXIST);
            }
            else
            {
                try
                {
                    var rmCred = this.ValidateUserCredentials(request.userName);
                    if (rmCred.Success)
                    {
                        IResultModel rmDelete = await this.projectService.DeleteProjectByUserAsync(request);

                        if (rmDelete.Success)
                        {
                            response.OnSuccess(new ProjectItemResponse()
                            {
                                item = new ProjectPOCO()
                                {
                                    Id = request.id
                                }
                            });
                        }
                        else
                        {
                            response.OnError(
                                ErrorResources.ModelStateErrors_Format.sf(rmDelete.ErrorMessage),
                                rmDelete.ErrorCode
                                );
                        }
                    }
                    else
                    {
                        response.OnError(rmCred.ErrorMessage, rmCred.ErrorCode);
                    }
                }
                catch (Exception ex)
                {
                    response.OnException(ex);
                }
            }

            httpResponse = Request.CreateResponse <IResultServiceModel <ProjectItemResponse> >(HttpStatusCode.Created, response);
            httpResponse.Headers.Location = new Uri(uri);

            return(httpResponse);
        }
Exemplo n.º 23
0
        public IResultServiceModel <Customer> GetCustomerbyProjectCode(string signUpCode, bool mustBeFree = true)
        {
            IResultServiceModel <Customer> rsm = new ResultServiceModel <Customer>();

            signUpCode = signUpCode.ToUpper();
            try
            {
                var customer = this.context.Customers
                               .Where(w => w.SignUpCode == signUpCode)
                               .FirstOrDefault();

                if (customer != null)
                {
                    if (mustBeFree)
                    {
                        if (string.IsNullOrWhiteSpace(customer.Email))
                        {
                            rsm.OnSuccess(customer);
                        }
                        else
                        {
                            rsm.OnError(CustomerResources.CustomerCodeHasBeenUsed);
                        }
                    }
                    else
                    {
                        rsm.OnSuccess(customer);
                    }
                }
                else
                {
                    rsm.OnError(CustomerResources.CustomerCodeDoesNotExist);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 24
0
        public async Task <IResultServiceModel <Project> > GetProjectByIdAndUserAsync(string userName, long id)
        {
            IResultServiceModel <Project> rsm = new ResultServiceModel <Project>();
            //get the user
            User   user      = null;
            string roleFlags = string.Empty;

            try
            {
                user = await this.accountService.FindUserByUserNameOrEmailAsync(userName);

                roleFlags = this.accountService.GetRolesKeyFlagsForUser(user.Id);

                //depending on the user, will see the whole list, part of it, or nothing
                if (roleFlags.Trim() == "C")
                {
                    rsm.OnSuccess(new Project());
                    rsm.Message = ProjectResources.CustomersCannotGetProjects;
                }
                else
                {
                    var rmsList = this.projectRepository.Find(id);
                    if (rmsList.Success)
                    {
                        rsm.OnSuccess(rmsList.Value);
                    }
                    else
                    {
                        rsm.OnError(rmsList.ErrorMessage, rmsList.ErrorCode);
                    }
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }
Exemplo n.º 25
0
        public async Task <HttpResponseMessage> Excel([FromBody] ProjectExcelRequest request)
        {
            HttpResponseMessage httpResponse = null;
            string uri    = Url.Link("ProjectExcelApi", new { id = request.id });
            string userId = request.userName;
            IResultServiceModel <ProjectExcelResponse> response = new ResultServiceModel <ProjectExcelResponse>();

            try
            {
                var rmCred = this.ValidateUserCredentials(request.userName);
                if (rmCred.Success)
                {
                    IResultServiceModel <string> rmsGUID;

                    rmsGUID = this.miscService.GenerateDownloadExcelFileId(request.id);

                    if (rmsGUID.Success)
                    {
                        var host = this.GetBaseUrl();
                        host = "{0}api/Project/DownloadExcel?guid={1}".sf(host, rmsGUID.Value);

                        var resp = new ProjectExcelResponse()
                        {
                            url = host
                        };

                        response.OnSuccess(resp);
                    }
                    else
                    {
                        response.OnError(rmsGUID.ErrorMessage, rmsGUID.ErrorCode);
                    }
                }
                else
                {
                    response.OnError(rmCred.ErrorMessage, rmCred.ErrorCode);
                }
            }
            catch (Exception ex)
            {
                response.OnException(ex);
            }


            httpResponse = Request.CreateResponse <IResultServiceModel <ProjectExcelResponse> >(HttpStatusCode.Created, response);
            httpResponse.Headers.Location = new Uri(uri);

            return(httpResponse);
        }
Exemplo n.º 26
0
        public IResultServiceModel <IEnumerable <Project> > GetActiveProjects()
        {
            IResultServiceModel <IEnumerable <Project> > rsm = new ResultServiceModel <IEnumerable <Project> >();

            try
            {
                var list = this.context.Projects.OrderByDescending(o => o.StartDate);

                return(rsm.OnSuccess(list));
            }
            catch (Exception ex)
            {
                return(rsm.OnException(ex));
            }
        }
Exemplo n.º 27
0
        public IResultServiceModel <IEnumerable <AppConfiguration> > GetOnlyPlatformParams()
        {
            var allowed = new string[] { EnumAppConfigurationKeyDefinition.PublicKey, EnumAppConfigurationKeyDefinition.DefaultTotalStandsPerEvent };
            IResultServiceModel <IEnumerable <AppConfiguration> > rsm = new ResultServiceModel <IEnumerable <AppConfiguration> >();

            try
            {
                var list = this.context.AppConfigurations.Where(w => allowed.Contains(w.Key));
                rsm.OnSuccess(list);
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }
            return(rsm);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Gets all.
        /// </summary>
        /// <returns></returns>
        public virtual IResultServiceModel <IEnumerable <T> > GetAll()
        {
            IResultServiceModel <IEnumerable <T> > rv = new ResultServiceModel <IEnumerable <T> >();

            try
            {
                return(rv.OnSuccess(
                           this.context
                           .Set <T>()
                           ));
            }
            catch (Exception ex)
            {
                return(rv.OnException(ex));
            }
        }
Exemplo n.º 29
0
        public async Task <HttpResponseMessage> CustomerActivity([FromUri] ProjectCustomerActivityRequest request)
        {
            IResultServiceModel <ProjectCustomerActivityResponse> response = new ResultServiceModel <ProjectCustomerActivityResponse>();

            var rmCred = this.ValidateUserCredentials(request.userName);

            if (rmCred.Success)
            {
                var cuz = this.mainService.GetCustomer(request.pId, request.id, request.userName);
                response.OnSuccess(
                    new ProjectCustomerActivityResponse()
                {
                    Customer = cuz.Value
                }
                    );
            }
            else
            {
                response.OnError(rmCred);
            }

            var httpResponse = Request.CreateResponse <IResultServiceModel <ProjectCustomerActivityResponse> >(HttpStatusCode.Created, response);

            return(await Task.FromResult(httpResponse));


            //IResultServiceModel<ProjectCustomerActivityResponse> response = new ResultServiceModel<ProjectCustomerActivityResponse>();

            //var rmCred = this.ValidateUserCredentials(request.userName);
            //if (rmCred.Success)
            //{
            //    var cuz = this.mainService.GetCustomerForProjectGeneralSpace(request.id, request.userName);
            //    response.OnSuccess(
            //        new ProjectCustomerActivityResponse()
            //        {
            //            Customer = new CustomerPOCO(cuz.Value)
            //        }
            //    );
            //}
            //else
            //{
            //    response.OnError(rmCred);
            //}

            //var httpResponse = Request.CreateResponse<IResultServiceModel<ProjectCustomerActivityResponse>>(HttpStatusCode.Created, response);
            //return await Task.FromResult(httpResponse);
        }
Exemplo n.º 30
0
        public IResultServiceModel <FileHistoryResponse> GetFileHistoryByFileAndUser(long fileId, User user, bool isOnlyCustomer)
        {
            IResultServiceModel <FileHistoryResponse> rsm = new ResultServiceModel <FileHistoryResponse>();
            FileHistoryResponse response = new FileHistoryResponse();
            bool authorized = true;

            try
            {
                var rmFile = this.fileRepository.Find(fileId);
                if (rmFile.Success)
                {
                    var file = rmFile.Value;
                    if (isOnlyCustomer)
                    {
                        //Authorization depends on whether the user is the owner or not
                        authorized = (file.Customer.UserId == user.Id);
                    }

                    if (authorized)
                    {
                        var rmStates = this.wfFileStateRepository.GetListByFileId(fileId);
                        response.File = new FilePOCO(file);

                        if (rmStates.Success)
                        {
                            response.States = rmStates.Value.Select(s => new WFFileStatePOCO(s));
                        }
                        else
                        {
                            response.States = Enumerable.Empty <WFFileStatePOCO>();
                        }

                        rsm.OnSuccess(response);
                    }
                }
                else
                {
                    rsm.OnError(CustomerResources.UserHasNotAuthorizationForThisFileHistory);
                }
            }
            catch (Exception ex)
            {
                rsm.OnException(ex);
            }

            return(rsm);
        }