Ejemplo n.º 1
0
        public ServiceCallResult <AddRequestViewModel> UpdateRequestAttachments()
        {
            try
            {
                List <int> attachIntIdList = new List <int>();
                var        keepAttach      = Request.Form.Where(f => f.Key.Contains("keep")).Select(s => s.Value.ToList());
                foreach (var at in keepAttach)
                {
                    foreach (var a in at)
                    {
                        int.TryParse(a, out int i);
                        attachIntIdList.Add(i);
                    }
                }
                var toDelete = _wtContext.RequestAttachments.Where(ra => ra.RequestId == int.Parse(Request.Form["id"].ToString()) && !attachIntIdList.Contains(ra.Id));
                _wtContext.RequestAttachments.RemoveRange(toDelete);
                _wtContext.SaveChanges();
                if (Request.Form.Files.Count() > 0)
                {
                    return(AddRequestAttachment());
                }
                Request ret = _wtContext.Requests
                              .Where(x => x.Id == int.Parse(Request.Form["id"].ToString()))
                              .Include(x => x.OwningStream)
                              .FirstOrDefault();
                var vm = Mappers <Request, AddRequestViewModel> .MapToViewModel(ret);

                return(ServiceCallResult <AddRequestViewModel> .CreateSuccessResult(String.Format(UserMessageResource.FieldAddedSuccessfully, FieldNamesResource.Request), vm));
            }
            catch (Exception ex)
            {
                return(ServiceCallResult <AddRequestViewModel> .CreateErrorResult(String.Format(UserMessageResource.ErrorAddingField, FieldNamesResource.Request) + ex.Message, new AddRequestViewModel()));
            }
        }
Ejemplo n.º 2
0
        public ServiceCallResult <List <RequestViewModel> > GetAllRequests(bool openRequestsOnly = false)
        {
            try
            {
                var vm = new List <RequestViewModel>();
                //var completedId = _wtContext.Statuses.Where(x => x.Name.ToLower() == "completed").FirstOrDefault().Id;
                //var cancelledId = _wtContext.Statuses.Where(x => x.Name.ToLower() == "cancelled").FirstOrDefault().Id;
                IQueryable <Request> query = _wtContext.Requests.Include(x => x.Status)
                                             .Include(x => x.Application)
                                             .Include(x => x.Regions).ThenInclude(x => x.Region)
                                             .Include(x => x.SBUs).ThenInclude(x => x.SBU)
                                             .Include(x => x.OwningSite)
                                             .Include(x => x.OwningStream)
                                             .Include(x => x.ImpactedStreams).ThenInclude(x => x.ImpactedStream)
                                             .Include(x => x.OraclePreProdEnvironments).ThenInclude(x => x.OraclePreProdEnvironment)
                                             .Include(x => x.BIRequest)
                                             .Include(x => x.Attachments);
                if (openRequestsOnly)
                {
                    query = query.Where(x => x.Status.Name.ToLower() != "completed" && x.Status.Name.ToLower() != "cancelled");
                }
                var requests = query.ToList();
                foreach (var r in requests)
                {
                    vm.Add(Mappers <Request, RequestViewModel> .MapToViewModel(r));
                }

                return(ServiceCallResult <List <RequestViewModel> > .CreateSuccessResult(String.Format(UserMessageResource.GetListSuccess, FieldNamesResource.Request), vm));
            }
            catch (Exception ex)
            {
                return(ServiceCallResult <List <RequestViewModel> > .CreateErrorResult(string.Format(UserMessageResource.GetListError, FieldNamesResource.Request) + " " + ex.Message, new List <RequestViewModel>()));
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> CallArloService(ServiceCall call)
        {
            var svc = ArloClient(call, TokenMorphers[call.Simulation]);

            ServiceCallResult result = await AttemptExecution(() => svc.Item1.SendAsync(svc.Item2));

            return(View("CallArloService", result));
        }
        public ServiceCallResult CreateBooking(Booking booking)
        {
            //int roomId = FindAvailableRoom(booking.StartDate, booking.EndDate);

            //if (roomId >= 0)
            //{
            //    booking.RoomId = roomId;
            //    booking.IsActive = true;
            //    bookingRepository.Add(booking);
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}

            var callResult = new ServiceCallResult()
            {
                Success = false
            };

            if (booking.StartDate < DateTime.Today)
            {
                callResult.ErrorMessages.Add("Geçmiş tarihli rezervasyon yapılamaz!");
                return(callResult);
            }

            if (booking.StartDate > booking.EndDate)
            {
                callResult.ErrorMessages.Add("Hatalı Tarih Seçimi");
                return(callResult);
            }

            var activeBooking = bookingRepository.GetAll().Where(x => x.RoomId == booking.RoomId && (x.EndDate > booking.StartDate && x.StartDate < booking.EndDate));

            if (activeBooking.Count() > 0)
            {
                callResult.ErrorMessages.Add("Bu tarih aralığında odamız doludur!");
                return(callResult);
            }

            var fark      = booking.EndDate - booking.StartDate;
            var totalDays = fark.TotalDays;
            var room      = roomRepository.Get(booking.RoomId);

            booking.Fiyat = room.Fiyat * totalDays;

            callResult.Success = true;
            callResult.SuccessMessages.Add("Rezervasyonunuz oluşturuldu. 'Sepete Ekle' butonuna tıklayınız.");
            booking.IsActive = true;
            bookingRepository.Add(booking);
            return(callResult);
        }
Ejemplo n.º 5
0
        public ServiceCallResult <RequestViewModel> UpdateRequestUserField(int requestId, string user, string fieldName)
        {
            try
            {
                _wtContext.SetCurrentUser(Auth.GetCurrentUser(User.Identity.Name).fullName);

                var existingRequest = _wtContext.Requests.Where(x => x.Id == requestId).FirstOrDefault();
                if (existingRequest != null)
                {
                    if (fieldName.ToLower() == "requestor")
                    {
                        existingRequest.Requestor = user;
                    }
                    else if (fieldName.ToLower() == "bicontact")
                    {
                        existingRequest.BIContact = user;
                    }
                    else if (fieldName.ToLower() == "functionalcontact")
                    {
                        existingRequest.FunctionalContact = user;
                    }
                    else if (fieldName.ToLower() == "frontlinecontact")
                    {
                        existingRequest.FrontLineContact = user;
                    }
                    else if (fieldName.ToLower() == "oracledevelopmentlead")
                    {
                        existingRequest.OracleDevelopmentLead = user;
                    }
                    else if (fieldName.ToLower() == "dcoedevelopmentlead")
                    {
                        existingRequest.DCOEDevelopmentLead = user;
                    }

                    _wtContext.SaveChanges();
                }
                else
                {
                    return(ServiceCallResult <RequestViewModel> .CreateErrorResult(String.Format(UserMessageResource.ErrorSavingInputInvalid, FieldNamesResource.Request, FieldNamesResource.Fields), new RequestViewModel()));
                }
                Request ret = _wtContext.Requests.Where(x => x.Id == requestId).FirstOrDefault();
                var     vm  = Mappers <Request, RequestViewModel> .MapToViewModel(ret);

                return(ServiceCallResult <RequestViewModel> .CreateSuccessResult(string.Format(UserMessageResource.FieldSavedSuccessfully, FieldNamesResource.Request), vm));
            }
            catch (Exception ex)
            {
                return(ServiceCallResult <RequestViewModel> .CreateErrorResult(string.Format(UserMessageResource.ErrorAddingField, FieldNamesResource.Request) + ex.Message, new RequestViewModel()));
            }
        }
Ejemplo n.º 6
0
 public ServiceCallResult <IEnumerable <OwningSiteViewModel> > GetOwningSites()
 {
     try
     {
         var data       = _dbrepository.GetOwningSites();
         var viewModels = new List <OwningSiteViewModel>();
         foreach (var d in data)
         {
             viewModels.Add(Mappers <OwningSite, OwningSiteViewModel> .MapToViewModel(d));
         }
         return(ServiceCallResult <IEnumerable <OwningSiteViewModel> > .CreateSuccessResult(String.Format(UserMessageResource.GetListSuccess, FieldNamesResource.OwningSite), viewModels));
     }
     catch (Exception ex)
     {
         return(ServiceCallResult <IEnumerable <OwningSiteViewModel> > .CreateErrorResult(String.Format(UserMessageResource.GetListError, FieldNamesResource.OwningSite) + " " + ex.Message, new List <OwningSiteViewModel>()));
     }
 }
Ejemplo n.º 7
0
 public ServiceCallResult <IEnumerable <ApplicationAttributeViewModel> > GetApplicationAttributeViews()
 {
     try
     {
         var data       = _dbrepository.GetApplicationAttributes();
         var viewModels = new List <ApplicationAttributeViewModel>();
         foreach (var d in data)
         {
             viewModels.Add(Mappers <ApplicationAttribute, ApplicationAttributeViewModel> .MapToViewModel(d));
         }
         return(ServiceCallResult <IEnumerable <ApplicationAttributeViewModel> > .CreateSuccessResult(String.Format(UserMessageResource.GetListSuccess, FieldNamesResource.RequestView), viewModels.OrderBy(o => o.Id)));
     }
     catch (Exception ex)
     {
         return(ServiceCallResult <IEnumerable <ApplicationAttributeViewModel> > .CreateErrorResult(String.Format(UserMessageResource.GetListError, FieldNamesResource.RequestView) + " " + ex.Message, new List <ApplicationAttributeViewModel>()));
     }
 }
Ejemplo n.º 8
0
        public ServiceCallResult <List <RequestNoteViewModel> > GetRequestNotes(int requestId)
        {
            try
            {
                var vm    = new List <RequestNoteViewModel>();
                var notes = _wtContext.RequestNotes.Where(x => x.RequestId == requestId).OrderByDescending(x => x.ModifiedOn).ToList();

                foreach (var n in notes)
                {
                    vm.Add(Mappers <RequestNote, RequestNoteViewModel> .MapToViewModel(n));
                }

                return(ServiceCallResult <List <RequestNoteViewModel> > .CreateSuccessResult(string.Format(UserMessageResource.GetListSuccess, FieldNamesResource.RequestNote), vm));
            }
            catch (Exception ex)
            {
                return(ServiceCallResult <List <RequestNoteViewModel> > .CreateErrorResult(string.Format(UserMessageResource.GetListError, FieldNamesResource.RequestNote) + " " + ex.Message, new List <RequestNoteViewModel>()));
            }
        }
Ejemplo n.º 9
0
        public ServiceCallResult <bool> AddRequestNote([FromBody] RequestNoteViewModel requestNote)
        {
            try
            {
                _wtContext.SetCurrentUser(Auth.GetCurrentUser(User.Identity.Name).fullName);

                RequestNote newRequestNote = new RequestNote();
                newRequestNote.RequestId = requestNote.RequestId;
                newRequestNote.Note      = requestNote.Note;

                _wtContext.RequestNotes.Add(newRequestNote);
                _wtContext.SaveChanges();

                return(ServiceCallResult <bool> .CreateSuccessResult(String.Format(UserMessageResource.FieldAddedSuccessfully, FieldNamesResource.RequestNote), true));
            }
            catch (Exception ex)
            {
                return(ServiceCallResult <bool> .CreateErrorResult(String.Format(UserMessageResource.ErrorAddingField, FieldNamesResource.RequestNote) + ex.Message, false));
            }
        }
Ejemplo n.º 10
0
        public ServiceCallResult Post(serviceSettings settings)
        {
            var result = new ServiceCallResult {
                Success = true
            };

            try
            {
                if (string.IsNullOrEmpty(settings.Address))
                {
                    settings.Address = configuration["address"];
                }
                result.Data = ServiceCall.Call(settings);
            } catch (Exception ex)
            {
                result.Success = false;
                result.Data    = ex.Message;
            }
            return(result);
        }
Ejemplo n.º 11
0
        public async Task <ServiceCallResult <UserViewModel> > GetCurrentUser()
        {
            ADServiceClient client = new ADServiceClient();
            IIdentity       id     = User.Identity;
            //var user = await client.GetUserInfoExtendedByNetworkIdStartsWithAsync(id.GetLogin(), "1");
            var user = await client.GetUserInfoExtendedByNetworkIdStartsWithAsync("CCC27", "1");

            var uvm = new UserViewModel();

            if (user != null && user.Length > 0)
            {
                uvm.displayName = user[0].FullName;
                uvm.userId      = user[0].NetworkId;
                uvm.email       = user[0].Email;
                uvm.Role        = await DetermineUserRoleAsync(id.GetLogin(), client);

                uvm.Role = await DetermineUserRoleAsync("CCC27", client);
            }


            return(ServiceCallResult <UserViewModel> .CreateSuccessResult("User Found", uvm));
        }
Ejemplo n.º 12
0
        private async Task <ServiceCallResult> AttemptExecution(Func <Task <HttpResponseMessage> > f)
        {
            ServiceCallResult ret = new ServiceCallResult();

            try {
                HttpResponseMessage response = await f();

                if (!response.IsSuccessStatusCode)
                {
                    ret.FailureCode = "Request failed - " + response.StatusCode.ToString();
                }
                ret.Headers =
                    String.Join("<br/>", response.Headers.Select(kvp => "<strong>" + kvp.Key + "</strong> "
                                                                 + string.Join(", ", kvp.Value))) + "<p></p>";
                ret.Body = await response.Content.ReadAsStringAsync();
            }
            catch (Exception ex) {
                ret.FailureCode = "Unexpected exception";
                ret.Body        = ex.ToString();
            }
            return(ret);
        }
Ejemplo n.º 13
0
        public IActionResult Create([Bind("StartDate,EndDate,UserId,RoomId,OtelId")] Booking booking)
        {
            if (ModelState.IsValid)
            {
                ServiceCallResult created = bookingManager.CreateBooking(booking);

                if (created.Success)
                {
                    TempData["SuccessNotification"] = created.SuccessMessages;
                    //return RedirectToAction(nameof(Index));
                    return(View(booking));
                }
                else
                {
                    TempData["ErrorNotification"] = created.ErrorMessages;
                    return(View(booking));
                }
            }

            //ViewData["CustomerId"] = new SelectList(customerRepository.GetAll(),"Id", "Name", booking.UserId);
            ViewBag.Status = "Rezervasyon oluşturulamadı, mevcut oda bulunmamakta.";
            return(View(booking));
        }
Ejemplo n.º 14
0
        public ServiceCallResult <AddRequestViewModel> AddRequestAttachment()
        {
            if (Request.Form.Files.Count() > 0)
            {
                try
                {
                    foreach (var file in Request.Form.Files)
                    {
                        RequestAttachment fileAttachment = new RequestAttachment();
                        var memoryStream = new MemoryStream();
                        file.CopyTo(memoryStream);
                        fileAttachment.Attachment = memoryStream.ToArray();
                        fileAttachment.FileName   = file.FileName;
                        fileAttachment.RequestId  = int.Parse(Request.Form["id"].ToString());
                        _wtContext.RequestAttachments.Add(fileAttachment);
                    }
                    _wtContext.SaveChanges();

                    Request ret = _wtContext.Requests
                                  .Where(x => x.Id == int.Parse(Request.Form["id"].ToString()))
                                  .Include(x => x.OwningStream)
                                  .FirstOrDefault();
                    var vm = Mappers <Request, AddRequestViewModel> .MapToViewModel(ret);

                    return(ServiceCallResult <AddRequestViewModel> .CreateSuccessResult(String.Format(UserMessageResource.FieldAddedSuccessfully, FieldNamesResource.Request), vm));
                }
                catch (Exception ex)
                {
                    return(ServiceCallResult <AddRequestViewModel> .CreateErrorResult(String.Format(UserMessageResource.ErrorAddingField, FieldNamesResource.Request) + ex.Message, new AddRequestViewModel()));
                }
            }
            else
            {
                return(ServiceCallResult <AddRequestViewModel> .CreateErrorResult(String.Format(UserMessageResource.ErrorSavingInputInvalid, FieldNamesResource.Request, FieldNamesResource.Fields), new AddRequestViewModel()));
            }
        }
Ejemplo n.º 15
0
        public ServiceCallResult <DropDownDataViewModel> GetDropDownData()
        {
            try
            {
                var vm   = new DropDownDataViewModel();
                var apps = _dbrepository.GetAppNames();
                vm.AppNames = new List <AppNameViewModel>();
                foreach (var a in apps)
                {
                    vm.AppNames.Add(Mappers <Application, AppNameViewModel> .MapToViewModel(a));
                }

                var regions = _dbrepository.GetRegions();
                vm.Regions = new List <RegionViewModel>();
                foreach (var r in regions)
                {
                    vm.Regions.Add(Mappers <Region, RegionViewModel> .MapToViewModel(r));
                }

                var sbus = _dbrepository.GetSBUs();
                vm.SBUs = new List <SBUViewModel>();
                foreach (var s in sbus)
                {
                    vm.SBUs.Add(Mappers <SBU, SBUViewModel> .MapToViewModel(s));
                }

                var owningsites = _dbrepository.GetOwningSites();
                vm.OwningSites = new List <OwningSiteViewModel>();
                foreach (var o in owningsites)
                {
                    vm.OwningSites.Add(Mappers <OwningSite, OwningSiteViewModel> .MapToViewModel(o));
                }


                var booleanDropDowns = _dbrepository.GetBooleanDropDowns();
                vm.BooleanDropDowns = new List <BooleanDropDownViewModel>();
                foreach (var b in booleanDropDowns)
                {
                    vm.BooleanDropDowns.Add(Mappers <BooleanDropDown, BooleanDropDownViewModel> .MapToViewModel(b));
                }

                var developmentTeams = _dbrepository.GetDevelopmentTeams();
                vm.DevelopmentTeams = new List <DevelopmentTeamViewModel>();
                foreach (var d in developmentTeams)
                {
                    vm.DevelopmentTeams.Add(Mappers <DevelopmentTeam, DevelopmentTeamViewModel> .MapToViewModel(d));
                }

                var gateStatuses = _dbrepository.GetGateStatuses();
                vm.GateStatuses = new List <GateStatusViewModel>();
                foreach (var g in gateStatuses)
                {
                    vm.GateStatuses.Add(Mappers <GateStatus, GateStatusViewModel> .MapToViewModel(g));
                }
                var gates = _dbrepository.GetGates();
                vm.Gates = new List <GateViewModel>();
                foreach (var g in gates)
                {
                    vm.Gates.Add(Mappers <Gate, GateViewModel> .MapToViewModel(g));
                }

                var owningStreams = _dbrepository.GetOwningStreams();
                vm.OwningStreams = new List <OwningStreamViewModel>();
                foreach (var o in owningStreams)
                {
                    vm.OwningStreams.Add(Mappers <OwningStream, OwningStreamViewModel> .MapToViewModel(o));
                }

                var impactedStreams = _dbrepository.GetImpactedStreams();
                vm.ImpactedStreams = new List <ImpactedStreamViewModel>();
                foreach (var i in impactedStreams)
                {
                    vm.ImpactedStreams.Add(Mappers <ImpactedStream, ImpactedStreamViewModel> .MapToViewModel(i));
                }

                var modules = _dbrepository.GetModules();
                vm.Modules = new List <ModuleViewModel>();
                foreach (var m in modules)
                {
                    vm.Modules.Add(Mappers <Module, ModuleViewModel> .MapToViewModel(m));
                }

                var oraclePreProdEnvironments = _dbrepository.GetOraclePreProdEnvironments();
                vm.OraclePreProdEnvironments = new List <OraclePreProdEnvironmentViewModel>();
                foreach (var o in oraclePreProdEnvironments)
                {
                    vm.OraclePreProdEnvironments.Add(Mappers <OraclePreProdEnvironment, OraclePreProdEnvironmentViewModel> .MapToViewModel(o));
                }

                var statuses = _dbrepository.GetStatuses();
                vm.Statuses = new List <StatusViewModel>();
                foreach (var s in statuses)
                {
                    vm.Statuses.Add(Mappers <Status, StatusViewModel> .MapToViewModel(s));
                }

                return(ServiceCallResult <DropDownDataViewModel> .CreateSuccessResult(String.Format(UserMessageResource.GetListSuccess, FieldNamesResource.RequestView), vm));
            }
            catch (Exception ex)
            {
                return(ServiceCallResult <DropDownDataViewModel> .CreateErrorResult(String.Format(UserMessageResource.GetListError, FieldNamesResource.RequestView) + " " + ex.Message, new DropDownDataViewModel()));
            }
        }
Ejemplo n.º 16
0
        public ServiceCallResult <RequestViewModel> UpdateRequest([FromBody] RequestViewModel request)
        {
            try
            {
                string previousStatus     = "";
                bool   owningStreamChange = false;
                bool   statusChange       = false;
                _wtContext.SetCurrentUser(Auth.GetCurrentUser(User.Identity.Name).fullName);
                if (!isRequestValid(request))
                {
                    return(ServiceCallResult <RequestViewModel> .CreateErrorResult(String.Format(UserMessageResource.ErrorSavingInputInvalid, FieldNamesResource.Request, FieldNamesResource.Fields), request));
                }

                var existingRequest = _wtContext.Requests.Include(x => x.Status).Include(x => x.OwningStream).Where(x => x.Id == request.Id).FirstOrDefault();
                if (existingRequest != null)
                {
                    existingRequest.ApplicationId = request.AppName.Id;
                    existingRequest.ProjectName   = request.ProjectName;
                    existingRequest.Problem       = request.Problem;
                    existingRequest.BenefitCase   = request.BenefitCase;
                    existingRequest.COEPriority   = request.COEPriority;
                    existingRequest.GBSPriority   = request.GBSPriority;
                    if (request.StatusId != existingRequest.StatusId)
                    {
                        previousStatus           = existingRequest.Status.Name;
                        existingRequest.StatusId = request.StatusId;
                    }
                    existingRequest.MD_50_DueDate = request.MD_50_DueDate != null?Convert.ToDateTime(request.MD_50_DueDate) : (DateTime?)null;

                    existingRequest.MD_70_DueDate = request.MD_70_DueDate != null?Convert.ToDateTime(request.MD_70_DueDate) : (DateTime?)null;

                    existingRequest.TestingDate = request.TestingDate != null?Convert.ToDateTime(request.TestingDate) : (DateTime?)null;

                    existingRequest.ProductionDate = request.ProductionDate != null?Convert.ToDateTime(request.ProductionDate) : (DateTime?)null;

                    existingRequest.TotalEstimate             = request.TotalEstimate;
                    existingRequest.OracleDevEstimateOffShore = request.OracleDevEstimateOffShore;
                    existingRequest.OracleDevEstimateOnShore  = request.OracleDevEstimateOnShore;
                    existingRequest.DCOEEstimate             = request.DCOEEstimate;
                    existingRequest.CRNo                     = request.CRNo;
                    existingRequest.FunctionalContact        = request.FunctionalContact;
                    existingRequest.BIContact                = request.BIContact;
                    existingRequest.OracleDevelopmentLead    = request.OracleDevelopmentLead;
                    existingRequest.DCOEDevelopmentLead      = request.DCOEDevelopmentLead;
                    existingRequest.MD_50                    = request.MD_50;
                    existingRequest.MD_70                    = request.MD_70;
                    existingRequest.TIPUrl                   = request.TIPUrl;
                    existingRequest.EBSGateQuestionnaireUrl  = request.EBSGateQuestionnaireUrl;
                    existingRequest.BIGateQuestionnaireUrl   = request.BIGateQuestionnaireUrl;
                    existingRequest._NETGateQuestionnaireUrl = request._NETGateQuestionnaireUrl;
                    existingRequest.OTMGateQuestionnaireUrl  = request.OTMGateQuestionnaireUrl;
                    existingRequest.ReadyForEBSGateId        = request.ReadyForEBSGate != null ? request.ReadyForEBSGate.Id : (int?)null;
                    existingRequest.EBSGateStatusId          = request.EBSGateStatus != null ? request.EBSGateStatus.Id : (int?)null;
                    existingRequest.NextEBSGateId            = request.NextEBSGate != null ? request.NextEBSGate.Id : (int?)null;
                    existingRequest.ReadyForOTMGateId        = request.ReadyForOTMGate != null ? request.ReadyForOTMGate.Id : (int?)null;
                    existingRequest.OTMGateStatusId          = request.OTMGateStatus != null ? request.OTMGateStatus.Id : (int?)null;
                    existingRequest.OTMEBSGateId             = request.OTMEBSGate != null ? request.OTMEBSGate.Id : (int?)null;
                    existingRequest.ReadyForBIGateId         = request.ReadyForBIGate != null ? request.ReadyForBIGate.Id : (int?)null;
                    existingRequest.BIGateStatusId           = request.BIGateStatus != null ? request.BIGateStatus.Id : (int?)null;
                    existingRequest.NextBIGateId             = request.NextBIGate != null ? request.NextBIGate.Id : (int?)null;
                    existingRequest.ReadyFor_NETGateId       = request.ReadyFor_NETGate != null ? request.ReadyFor_NETGate.Id : (int?)null;
                    existingRequest._NETGateStatusId         = request._NETGateStatus != null ? request._NETGateStatus.Id : (int?)null;
                    existingRequest.Next_NETGateId           = request.Next_NETGate != null ? request.Next_NETGate.Id : (int?)null;
                    existingRequest.EstimateInfra            = request.EstimateInfra;
                    existingRequest.FrontLineContact         = request.FrontLineContact;
                    existingRequest.OwningSiteId             = request.OwningSite != null ? request.OwningSite.Id : (int?)null;

                    existingRequest.Requestor               = request.Requestor;
                    existingRequest.BIRequestId             = request.BIRequestId;
                    existingRequest.OriginalSystemReference = request.OriginalSystemReference;
                    existingRequest.Attribute1              = request.Attribute1;
                    existingRequest.Attribute2              = request.Attribute2;
                    existingRequest.Attribute3              = request.Attribute3;
                    existingRequest.Attribute4              = request.Attribute4;
                    existingRequest.Attribute5              = request.Attribute5;
                    existingRequest.Attribute6              = request.Attribute6;
                    existingRequest.Attribute7              = request.Attribute7;
                    existingRequest.Attribute8              = request.Attribute8;
                    existingRequest.Attribute9              = request.Attribute9;
                    existingRequest.Attribute10             = request.Attribute10 != null?Convert.ToDateTime(request.Attribute10) : (DateTime?)null;

                    //default these values to false, set them to true whether values exist in impacted stream array.
                    existingRequest.BIImpactedStream  = false;
                    existingRequest.OTMImpactedStream = false;

                    //Change Valid
                    if (existingRequest.StatusId != request.Status.Id)
                    {
                        statusChange             = true;
                        existingRequest.StatusId = request.Status.Id;
                    }

                    if (existingRequest.OwningStreamId != request.OwningStream.Id)
                    {
                        owningStreamChange             = true;
                        existingRequest.OwningStreamId = request.OwningStream.Id;
                    }

                    //regions
                    var regions = _wtContext.RequestRegions.Where(x => x.RequestId == request.Id).ToList();
                    _wtContext.RequestRegions.RemoveRange(regions);
                    foreach (var r in request.Regions)
                    {
                        var reg = new RequestRegion();
                        reg.RequestId = request.Id;
                        reg.RegionId  = r.Id;
                        _wtContext.RequestRegions.Add(reg);
                    }

                    //sbus
                    var sbus = _wtContext.RequestSBUs.Where(x => x.RequestId == request.Id).ToList();
                    _wtContext.RequestSBUs.RemoveRange(sbus);
                    foreach (var s in request.SBUs)
                    {
                        var sbu = new RequestSBU();
                        sbu.RequestId = request.Id;
                        sbu.SBUId     = s.Id;
                        _wtContext.RequestSBUs.Add(sbu);
                    }
                    //impactedstreams
                    var impactedstreams = _wtContext.RequestImpactedStreams.Where(x => x.RequestId == request.Id).ToList();
                    _wtContext.RequestImpactedStreams.RemoveRange(impactedstreams);
                    foreach (var i in request.ImpactedStreams)
                    {
                        var ist = new RequestImpactedStream();
                        ist.RequestId        = request.Id;
                        ist.ImpactedStreamId = i.Id;
                        if (i.Name.ToUpper() == "BI")
                        {
                            existingRequest.BIImpactedStream = true;
                        }
                        if (i.Name.ToUpper() == "OTM")
                        {
                            existingRequest.OTMImpactedStream = true;
                        }

                        _wtContext.RequestImpactedStreams.Add(ist);
                    }
                    //modules
                    var modules = _wtContext.RequestModules.Where(x => x.RequestId == request.Id).ToList();
                    _wtContext.RequestModules.RemoveRange(modules);
                    foreach (var i in request.Modules)
                    {
                        var mod = new RequestModule();
                        mod.RequestId = request.Id;
                        mod.ModuleId  = i.Id;
                        _wtContext.RequestModules.Add(mod);
                    }
                    //developmentteams
                    var developmentteams = _wtContext.RequestDevelopmentTeams.Where(x => x.RequestId == request.Id).ToList();
                    _wtContext.RequestDevelopmentTeams.RemoveRange(developmentteams);
                    foreach (var i in request.DevelopmentTeams)
                    {
                        var dt = new RequestDevelopmentTeam();
                        dt.RequestId         = request.Id;
                        dt.DevelopmentTeamId = i.Id;
                        _wtContext.RequestDevelopmentTeams.Add(dt);
                    }
                    //oraclepreprodenvironments
                    var oracleenvs = _wtContext.RequestOraclePreProdEnvironments.Where(x => x.RequestId == request.Id).ToList();
                    _wtContext.RequestOraclePreProdEnvironments.RemoveRange(oracleenvs);
                    foreach (var i in request.OraclePreProdEnvironments)
                    {
                        var oe = new RequestOraclePreProdEnvironment();
                        oe.RequestId = request.Id;
                        oe.OraclePreProdEnvironmentId = i.Id;
                        _wtContext.RequestOraclePreProdEnvironments.Add(oe);
                    }

                    //add note if status has changed
                    if (!string.IsNullOrEmpty(previousStatus))
                    {
                        var note = new RequestNote();
                        note.RequestId = request.Id;
                        note.Note      = "Status Changed from " + previousStatus + " to " + request.Status.Name;
                        _wtContext.RequestNotes.Add(note);
                    }
                    //attachments

                    _wtContext.SaveChanges();
                }
                else
                {
                    return(ServiceCallResult <RequestViewModel> .CreateErrorResult(String.Format(UserMessageResource.ErrorSavingInputInvalid, FieldNamesResource.Request, FieldNamesResource.Fields), request));
                }
                Request ret = _wtContext.Requests.Where(x => x.Id == request.Id)
                              .Include(x => x.Application)
                              .Include(x => x.Attachments)
                              .Include(x => x.Status)
                              .Include(x => x.Regions).ThenInclude(x => x.Region)
                              .Include(x => x.SBUs).ThenInclude(x => x.SBU)
                              .Include(x => x.OwningSite)
                              .Include(x => x.OwningStream)
                              .Include(x => x.ImpactedStreams).ThenInclude(x => x.ImpactedStream)
                              .Include(x => x.Modules).ThenInclude(x => x.Module)
                              .Include(x => x.DevelopmentTeams).ThenInclude(x => x.DevelopmentTeam)
                              .Include(x => x.OraclePreProdEnvironments).ThenInclude(x => x.OraclePreProdEnvironment)
                              .Include(x => x.BIRequest)
                              .Include(x => x.BIGateStatus)
                              .Include(x => x.NextBIGate)
                              .Include(x => x.ReadyForBIGate)
                              .Include(x => x._NETGateStatus)
                              .Include(x => x.Next_NETGate)
                              .Include(x => x.ReadyFor_NETGate)
                              .Include(x => x.EBSGateStatus)
                              .Include(x => x.NextEBSGate)
                              .Include(x => x.ReadyForEBSGate)
                              .Include(x => x.OTMGateStatus)
                              .Include(x => x.OTMEBSGate)
                              .Include(x => x.ReadyForOTMGate).FirstOrDefault();

                OwningStream owningStream = _wtContext.OwningStreams.Where(n => n.Id == request.OwningStream.Id).FirstOrDefault();
                string       email        = string.Empty;

                if (owningStream != null)
                {
                    email = owningStream.dlEmailAddress;
                }

                //Send Notifications
                if (statusChange)
                {
                    string title = "New Oracle COE Request Logged";
                    sendNotificationEmail(ret, EmailType.OwningStreamChange, title, email);
                }

                if (owningStreamChange)
                {
                    string title = "New Oracle COE Request Logged";
                    sendNotificationEmail(ret, EmailType.OwningStreamChange, title, email);
                }

                var vm = Mappers <Request, RequestViewModel> .MapToViewModel(ret);

                return(ServiceCallResult <RequestViewModel> .CreateSuccessResult(string.Format(UserMessageResource.FieldSavedSuccessfully, FieldNamesResource.Request), vm));
            }
            catch (Exception ex)
            {
                return(ServiceCallResult <RequestViewModel> .CreateErrorResult(string.Format(UserMessageResource.ErrorAddingField, FieldNamesResource.Request) + ex.Message, new RequestViewModel()));
            }
        }
Ejemplo n.º 17
0
        public ServiceCallResult <AddRequestViewModel> AddRequest([FromBody] AddRequestViewModel request)
        {
            try
            {
                _wtContext.SetCurrentUser(Auth.GetCurrentUser(User.Identity.Name).fullName);
                if (!isRequestValid(request))
                {
                    return(ServiceCallResult <AddRequestViewModel> .CreateErrorResult(String.Format(UserMessageResource.ErrorSavingInputInvalid, FieldNamesResource.Request, FieldNamesResource.Fields), request));
                }
                Request newRequest = new Request();
                newRequest.ApplicationId           = request.AppName.Id;
                newRequest.ProjectName             = request.ProjectName;
                newRequest.Problem                 = request.Problem;
                newRequest.BenefitCase             = request.BenefitCase;
                newRequest.BIRequestId             = request.BiRequestId;
                newRequest.OriginalSystemReference = request.OriginalSystemReference;
                newRequest.Requestor               = request.Requestor;
                if (request.OwningSite != null && request.OwningSite.Id != 0)
                {
                    newRequest.OwningSiteId = request.OwningSite.Id;
                }
                newRequest.OwningStreamId = request.OwningStream.Id;
                newRequest.StatusId       = _wtContext.Statuses.Where(x => x.Name.ToLower() == "new" && x.DeleteMark == false).FirstOrDefault().Id;
                int no = _wtContext.BooleanDropDownValues.Where(x => x.Name.ToLower() == "no").FirstOrDefault().Id;
                newRequest.ReadyForBIGateId   = no;
                newRequest.ReadyForEBSGateId  = no;
                newRequest.ReadyForOTMGateId  = no;
                newRequest.ReadyFor_NETGateId = no;

                _wtContext.Requests.Add(newRequest);
                _wtContext.SaveChanges();

                Request addedRequest = _wtContext.Requests
                                       .Where(x => x.ProjectName == request.ProjectName)
                                       .OrderByDescending(y => y.CreatedOn)
                                       .Include(i => i.OwningStream)
                                       .Include(i => i.OwningSite)
                                       .FirstOrDefault();

                if (addedRequest != null)
                {
                    //add Regions
                    foreach (var r in request.Regions)
                    {
                        var reg = new RequestRegion();
                        reg.RequestId = addedRequest.Id;
                        reg.RegionId  = r.Id;
                        //reg.Region = Mappers<Region, RegionViewModel>.MapToEntity(r);
                        _wtContext.RequestRegions.Add(reg);
                    }
                    //add SBUs
                    foreach (var s in request.SBUs)
                    {
                        var sbu = new RequestSBU();
                        sbu.RequestId = addedRequest.Id;
                        sbu.SBUId     = s.Id;
                        //sbu.SBU = Mappers<SBU, SBUViewModel>.MapToEntity(s);
                        _wtContext.RequestSBUs.Add(sbu);
                    }
                    //add attachments

                    _wtContext.SaveChanges();
                }

                Request ret = _wtContext.Requests
                              .Where(x => x.ProjectName == request.ProjectName)
                              .Include(x => x.OwningStream)
                              .Include(x => x.BIRequest)
                              .OrderByDescending(y => y.CreatedOn)
                              .FirstOrDefault();
                var vm = Mappers <Request, AddRequestViewModel> .MapToViewModel(ret);

                string title = "New Oracle COE Request Logged";
                sendNotificationEmail(ret, EmailType.NewRequestAdded, title, string.Empty);
                return(ServiceCallResult <AddRequestViewModel> .CreateSuccessResult(String.Format(UserMessageResource.FieldAddedSuccessfully, FieldNamesResource.Request), vm));
            }
            catch (Exception ex)
            {
                return(ServiceCallResult <AddRequestViewModel> .CreateErrorResult(String.Format(UserMessageResource.ErrorAddingField, FieldNamesResource.Request) + ex.Message, new AddRequestViewModel()));
            }
        }
Ejemplo n.º 18
0
 public static IActionResult PrepareServiceCallResponse <T>(ControllerBase controllerBase, bool isServiceProcessSuccess, ServiceCallResult <T> response)
 {
     if (isServiceProcessSuccess)
     {
         return(controllerBase.Ok(response.ServiceResponse));
     }
     else
     {
         return(controllerBase.StatusCode(StatusCodes.Status500InternalServerError, response.ServiceResponse));
     }
 }
Ejemplo n.º 19
0
        public ServiceCallResult <List <RequestViewModel> > GetRequestViewData(int viewId, bool openRequestsOnly = false)
        {
            try
            {
                var vm   = new List <RequestViewModel>();
                var view = _wtContext.RequestViews.Where(x => x.Id == viewId).FirstOrDefault();
                if (view != null)
                {
                    List <int> requestIds = new List <int>();
                    DbCommand  command    = _wtContext.Database.GetDbConnection().CreateCommand();
                    command.CommandText  = "select id from requests ";
                    command.CommandText += string.IsNullOrEmpty(view.WhereClaus) ? "" : "where " + view.WhereClaus;
                    _wtContext.Database.OpenConnection();
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            requestIds.Add((int)reader["id"]);
                        }
                    }

                    IQueryable <Request> query = _wtContext.Requests
                                                 .OrderBy(string.IsNullOrEmpty(view.OrderBy) ? "id desc" : view.OrderBy)
                                                 .Include(x => x.Application)
                                                 .Include(x => x.Status)
                                                 .Include(x => x.Regions).ThenInclude(x => x.Region)
                                                 .Include(x => x.SBUs).ThenInclude(x => x.SBU)
                                                 .Include(x => x.OwningSite)
                                                 .Include(x => x.OwningStream)
                                                 .Include(x => x.ImpactedStreams).ThenInclude(x => x.ImpactedStream)
                                                 .Include(x => x.Modules).ThenInclude(x => x.Module)
                                                 .Include(x => x.DevelopmentTeams).ThenInclude(x => x.DevelopmentTeam)
                                                 .Include(x => x.OraclePreProdEnvironments).ThenInclude(x => x.OraclePreProdEnvironment)
                                                 .Include(x => x.BIRequest)
                                                 .Include(x => x.BIGateStatus)
                                                 .Include(x => x.NextBIGate)
                                                 .Include(x => x.ReadyForBIGate)
                                                 .Include(x => x._NETGateStatus)
                                                 .Include(x => x.Next_NETGate)
                                                 .Include(x => x.ReadyFor_NETGate)
                                                 .Include(x => x.EBSGateStatus)
                                                 .Include(x => x.NextEBSGate)
                                                 .Include(x => x.ReadyForEBSGate)
                                                 .Include(x => x.OTMGateStatus)
                                                 .Include(x => x.OTMEBSGate)
                                                 .Include(x => x.ReadyForOTMGate)
                                                 .Include(x => x.Attachments);
                    query = query.Where(x => requestIds.Contains(x.Id));

                    if (openRequestsOnly)
                    {
                        query = query.Where(x => x.Status.Name.ToLower() != "completed" && x.Status.Name.ToLower() != "cancelled");
                    }
                    var requests = query.ToList();
                    foreach (var r in requests)
                    {
                        vm.Add(Mappers <Request, RequestViewModel> .MapToViewModel(r));
                    }
                }
                else
                {
                    return(ServiceCallResult <List <RequestViewModel> > .CreateErrorResult(string.Format(UserMessageResource.CannotFindFieldInDatabase, FieldNamesResource.RequestView), new List <RequestViewModel>()));
                }
                return(ServiceCallResult <List <RequestViewModel> > .CreateSuccessResult(string.Format(UserMessageResource.GetListSuccess, FieldNamesResource.Request), vm));
            }
            catch (Exception ex)
            {
                return(ServiceCallResult <List <RequestViewModel> > .CreateErrorResult(string.Format(UserMessageResource.GetListError, FieldNamesResource.Request) + " " + ex.Message, new List <RequestViewModel>()));
            }
        }