public int PostRequestDTO(RequestDTO requestDTO)
        {
            return(_requestRepository.Add(requestDTO));
            // _requestRepository.Save();

            //return CreatedAtAction("GetRequestDTO", new { id = requestDTO.Id }, requestDTO);
        }
Exemple #2
0
        public void Create(Guid senderId, Vehicle vehicle, Trailer trailer)
        {
            var request = Request.Create(senderId, vehicle, trailer);

            requestRepository.Add(request);
            persistenceContext.SaveChanges();
        }
Exemple #3
0
 public int Create(Request request)
 {
     requestValidator.ValidateAdd(request);
     GiveNewRequestFormat(request);
     FormatAFValues(request);
     requestRepository.Add(request);
     requestRepository.SaveChanges();
     return(request.RequestNumber);
 }
        //Create an item borrow request
        public bool AddItemBorrowRequest(Request request)
        {
            request.Status = RequestStatus.Pending;
            _requestRepository.Add(request);



            return(SaveRequest() > 0 ? true : false);
        }
Exemple #5
0
        public IHttpActionResult PostRequest(Request request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Add(request);

            return(CreatedAtRoute("DefaultApi", new { id = request.Id }, request));
        }
Exemple #6
0
 public void CreateRequest(CreateRequest request)
 {
     this.ValidateCreateRequest(request);
     using (IUnitOfWork uow = new UnitOfWork(RepositoryType.MSSQL))
     {
         IRequestRepository repo = IoC.Container.Resolve <IRequestRepository>(uow);
         Request            item = new Request(request.Subject, request.Description, request.Email);
         repo.Add(item);
         uow.Commit();
     }
 }
        public IActionResult Post([FromBody] Request request)
        {
            try
            {
                _requestRepository.Add(request);

                return Ok(request.Id);
            }
            catch (Exception ex)
            {
                return BadRequest(ex.ToString());
            }
        }
        public void InsertWordToRequestedWords(string word)
        {
            RequestEntity existingRequestWord = _requestRepository.GetByWord(word);

            if (existingRequestWord == null)
            {
                RequestEntity requestEntity = new RequestEntity()
                {
                    Word = word
                };
                _requestRepository.Add(requestEntity);
            }
        }
        /// <summary>
        /// ذخیره درخواست کمیسیون یا شورا به همراه پروفایل و دانشجو و شخص
        /// </summary>
        /// <param name="commissionModel"></param>
        /// <returns></returns>
        public Tuple <bool, string, long> AddCommissionRequest(CommissionModel commissionModel, long universityId)
        {
            try
            {
                //واکشی درخواست اگر وجود دارد
                var request = _requestRepository.Where(i => i.Id == commissionModel.Id).Include(i => i.Commission)
                              .Include(i => i.MemberMaster).FirstOrDefault() ?? new Request();
                request.RequestType            = commissionModel.RequestType;
                request.NumberofRemainingUnits = commissionModel.NumberofRemainingUnits;
                request.NumberofSpentUnits     = commissionModel.NumberofSpentUnits;
                request.RequestStatus          = commissionModel.RequestStatus;
                request.Description            = commissionModel.Description;
                request.MemberMaster           = _memberMasterRepository.Where(d => d.RequestType == RequestType.Comision)
                                                 .OrderByDescending(p => p.Id).FirstOrDefault();

                var x = new PersianCalendar();
                commissionModel.Date =
                    x.ToDateTime(commissionModel.Date.Year, commissionModel.Date.Month, commissionModel.Date.Day, 0, 0, 0, 0, 0);
                //درج درخواست به همراه کمیسیون
                if (request.Id > 0)
                {
                    request.Commission.CommissionNumber = commissionModel.CommissionNumber;
                    request.Commission.Date             = commissionModel.Date;
                    request.Commission.Description      = commissionModel.Description;
                    _requestRepository.Update(request);
                }
                else
                {
                    request.PersonId   = commissionModel.PersonId;
                    request.Commission = new Commission
                    {
                        CommissionNumber = commissionModel.CommissionNumber,
                        Date             = commissionModel.Date,
                        Description      = commissionModel.Description
                    };
                    _requestRepository.Add(request);
                }
                //آپدیت موارد خاص آموزشی مربوط به درخواست
                _commissionSpecialEducationRepository.Delete(c => c.CommissionId == commissionModel.Id);
                commissionModel.CommissionSpecialEducations.ForEach(c => c.CommissionId = commissionModel.Id);
                _commissionSpecialEducationRepository.Add(commissionModel.CommissionSpecialEducations);
                _unitOfWork.SaveChanges();
                return(new Tuple <bool, string, long>(true, "عملیات ثبت به درستی انجام شد", request.Id));
            }
            catch (Exception exception)
            {
                return(new Tuple <bool, string, long>(false, "خطا در ثبت درخواست", 0));
            }
        }
Exemple #10
0
        public bool AddRequest(RequestViewModel model)
        {
            Request newInstance = _mapper.Map <Request>(model);

            newInstance.RequestId = Guid.NewGuid();
            try
            {
                _requestRepository.Add(newInstance);
                _requestRepository.Save();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        /// <summary>
        /// ذخیره درخواست شورا به همراه پروفایل و دانشجو و شخص
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        public Tuple <bool, string, long> AddCouncilRequest(CouncilModel requestModel, long universityId)
        {
            try
            {
                //واکشی درخواست اگر وجود دارد
                var request = _requestRepository.Where(i => i.Id == requestModel.Id).Include(i => i.Council)
                              .Include(i => i.MemberMaster).FirstOrDefault() ?? new Request();
                request.RequestType            = requestModel.RequestType;
                request.NumberofRemainingUnits = requestModel.NumberofRemainingUnits;
                request.NumberofSpentUnits     = requestModel.NumberofSpentUnits;
                request.RequestStatus          = requestModel.RequestStatus;
                request.Description            = requestModel.Description;
                request.MemberMaster           = _memberMasterRepository.Where(d => d.RequestType == RequestType.Council)
                                                 .OrderByDescending(p => p.Id).FirstOrDefault();

                var x = new PersianCalendar();
                requestModel.Date =
                    x.ToDateTime(requestModel.Date.Year, requestModel.Date.Month, requestModel.Date.Day, 0, 0, 0, 0, 0);
                //درج درخواست به همراه شورا
                if (request.Id > 0)
                {
                    request.Council.CouncilNumber = requestModel.CouncilNumber;
                    request.Council.Date          = requestModel.Date;
                    request.Council.Description   = requestModel.Description;
                    request.Council.ProblemText   = requestModel.ProblemsCouncil;
                    _requestRepository.Update(request);
                }
                else
                {
                    request.PersonId = requestModel.PersonId;
                    request.Council  = new Council
                    {
                        CouncilNumber = requestModel.CouncilNumber,
                        Date          = requestModel.Date,
                        ProblemText   = requestModel.ProblemsCouncil,
                        Description   = requestModel.Description
                    };
                    _requestRepository.Add(request);
                }
                _unitOfWork.SaveChanges();
                return(new Tuple <bool, string, long>(true, "عملیات ثبت به درستی انجام شد", request.Id));
            }
            catch (Exception exception)
            {
                return(new Tuple <bool, string, long>(false, "خطا در ثبت درخواست", 0));
            }
        }
Exemple #12
0
        public override Request Add(Request entity)
        {
            ValidateBusinessRules(entity);
            //ValidationSameRankRequest(entity);
            WarningInfoVo warningInfoVo;
            var           listRequest = WarningProcess(entity, out warningInfoVo);
            var           result      = listRequest.FirstOrDefault(o => o.Id == entity.Id);

            //if (result != null && result.IsWarning.GetValueOrDefault() && !result.Confirm.GetValueOrDefault())
            //{
            //    warningInfoVo.IsUpdate = false;
            //    result.WarningInfo = warningInfoVo;
            //    return result;
            //}

            foreach (var request in listRequest)
            {
                if (request.Id == 0)
                {
                    result = request;
                    _requestRepository.Add(result);
                }
                else
                {
                    _requestRepository.Update(request);
                }
            }
            _requestRepository.Commit();
            return(result);
            //var request = base.Add(entity);

            //if (entity.SaveSystemEvent ?? true)
            //{
            //    var courier = _courierRepository.GetById(entity.CourierId.GetValueOrDefault()).User;

            //    _systemEventRepository.Add(EventMessage.RequestCreated,
            //            new Dictionary<EventMessageParam, string>()
            //                {
            //                    {EventMessageParam.Request, request.RequestNo},
            //                    {EventMessageParam.Courier, courier.LastName + " " + courier.FirstName + (string.IsNullOrEmpty(courier.MiddleName) ? "" : " " + courier.MiddleName)},
            //                });
            //    _systemEventRepository.Commit();
            //}

            //return request;
        }
        public IActionResult PostRequestDeactivatePuzzle(Request request)
        {
            UserProfile userProfile = GetCurrentUserProfile();
            var         userId      = userProfile.Id;

            request.RequestingPuzzleUserId = userId;
            request.CreateDateTime         = DateTime.Now;
            //adding new request for the puzzle
            _requestRepository.Add(request);
            //new instance of puzzle
            Puzzle puzzle = new Puzzle();

            //need to specify id of puzzle to know which one to deactivate and take away from shared puzzle list
            puzzle.Id = request.PuzzleId;
            //deactivate puzzle and remove from shared puzzle list
            _puzzleRepository.DeactivatePuzzle(puzzle.Id);
            return(Ok());
        }
Exemple #14
0
        public async Task <AddRequestDto> AddRequest(RequestDto dto)
        {
            var addRequestDto = new AddRequestDto();
            var request       = _mapper.Map <Request>(dto);
            var notification  = request.ValidationErrors();

            if (notification.HasErrors())
            {
                addRequestDto.Notification = notification;
                return(addRequestDto);
            }

            _requestRepository.Add(request);
            await _requestRepository.Commit();

            addRequestDto.Id = request.Id;

            return(_mapper.Map <AddRequestDto>(request));
        }
Exemple #15
0
        /// <summary>
        /// Create a new request.
        /// </summary>
        /// <param name="userId"> User's id to link.</param>
        /// <param name="playerId"> Player's id to link</param>
        public void Create(int userId, int playerId)
        {
            var requestExists = _getRequestUserPlayerQuery.Execute(
                new UserToPlayerCriteria {
                UserId = userId, PlayerId = playerId
            });

            if (requestExists == null)
            {
                var requestToCreate = new Request
                {
                    PlayerId = playerId,
                    UserId   = userId
                };

                _requestRepository.Add(requestToCreate);
                _requestRepository.UnitOfWork.Commit();
            }
        }
        public async Task <IActionResult> Request(Request request)
        {
            var model = new Request();

            model.UserDOB       = request.UserDOB;
            model.Email         = request.Email;
            model.UserFirstName = request.UserFirstName;
            model.UserLastName  = request.UserLastName;
            var email = model.Email;
            var dob   = model.UserDOB;

            _requestRepository.Add(model);
            var allRequests = _requestRepository.GetAll();

            model.Count = _requestRepository.CountAll(allRequests);


            // await _chatHub.SendMessage(email, dob);
            return(RedirectToAction("Index", "Admin", model));
        }
        public async Task <IActionResult> solveCalculation(string calculation)
        {
            var request = new Request();

            request.IpAddress       = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();
            request.RequestDateTime = DateTime.Now;
            _repo.Add(request);
            await _repo.SaveAll();

            try
            {
                var result = await _calc.evaluatePostfix(calculation);

                return(Ok(result));
            }
            catch (System.Exception ex)
            {
                throw new Exception("Error with calculation: " + ex.Message);
            }
        }
Exemple #18
0
        public IActionResult CreateRequest([FromBody] Request request)
        {
            if (request == null)
            {
                return(BadRequest());
            }

            _repository.Add(request);
            RequestStatus status = new RequestStatus()
            {
                Id        = request.Id,
                Status    = RequestStatusTypes.InTransit,
                SourceId  = "SERVER_ID",
                Timestamp = DateTime.UtcNow,
            };

            _statusRepository.Add(status);

            return(CreatedAtRoute("GetRequest", new { id = request.Key }, request));
        }
        public Request CreateRequest(Guid driverId, string registrationNumber)
        {
            Request request = new Request()
            {
                Id = Guid.NewGuid(),
            };
            var driver = DriverRepository.GetRouteWithVehicle(driverId);

            if (driver.CurrentRoute != null)
            {
                var trailer = TrailerRepository.GetByRegistrationNumber(registrationNumber);
                request.SetTrailer(trailer);

                request.SetVehicle(driver.CurrentRoute.Vehicle);
                request.SetStatus(RequestStatus.Active);
                request.SetSender(driver.Id);
                RequestRepository.Add(request);
                PersistenceContext.SaveChanges();
            }
            return(request);
        }
Exemple #20
0
        /// <summary>
        /// Метод отрабатывает вызов реализации добавления заявки через репозиторий
        /// </summary>
        /// <param name="item"></param>
        public bool AddRequest(DtoCreateRequest item, out string errorMsg)
        {
            errorMsg = "";
            var newRequest = new Request();

            //Маппим и устанавливаем статус
            if (!_requestServiceHelper.MapDtoCreateRequestToRequest(item, out newRequest, out errorMsg))
            {
                return(false);
            }

            //добавляем заявку
            try
            {
                _requestRepository.Add(newRequest);

                return(true);
            }
            catch (Exception)
            {
                errorMsg = "Ошибка добавления заявки";
                return(false);
            }
        }
        public async Task <IActionResult> Create(CreateRequestViewModel model)
        {
            model.ApplicationUserID = userManager.GetUserId(HttpContext.User);
            if (ModelState.IsValid)
            {
                var user = await userManager.GetUserAsync(HttpContext.User);

                if (model.StartDate > model.EndDate)
                {
                    ModelState.AddModelError("", "End Date must be after Start Date.");
                }
                else
                {
                    var conCheck = conflictCheck(user, model.StartDate, model.EndDate);

                    if (conCheck != 0)
                    {
                        ModelState.AddModelError("", "This conflicts with Request ID : " + conCheck);
                        return(View(model));
                    }

                    if (model.SpecialCase == "Business Trip")
                    {
                        Request newRequest = new Request
                        {
                            ApplicationUserID = model.ApplicationUserID,
                            StartDate         = model.StartDate,
                            EndDate           = model.EndDate,
                            SpecialCase       = "Business Trip to " + model.BusinessTripLocation
                        };
                        requestRepository.Add(newRequest);

                        // Send Emails
                        string[] otherUserEmails = getOtherUserEmails(user);
                        if (otherUserEmails.Any())
                        {
                            var otherUsersMessage = new Message(otherUserEmails, user.Email + " Has Scheduled A Business Trip", user.Email + " has scheduled a business trip for " + model.StartDate.ToShortDateString() + " thru " + model.EndDate.ToShortDateString() + " to visit " + model.BusinessTripLocation + ".<br><br>Please add it to your calendar.", "#", "");
                            await emailSender.SendEmailAsync(otherUsersMessage);
                        }

                        await emailTimeOffSummary(user, "scheduled a business trip for " + model.StartDate.ToShortDateString() + " thru " + model.EndDate.ToShortDateString() + " to visit " + model.BusinessTripLocation + ". ");

                        return(RedirectToAction("index"));
                    }
                    else if (model.SpecialCase == "Unpaid")
                    {
                        Request newRequest = new Request
                        {
                            ApplicationUserID = model.ApplicationUserID,
                            StartDate         = model.StartDate,
                            EndDate           = model.EndDate,
                            SpecialCase       = "Unpaid Personal/Vacation"
                        };
                        requestRepository.Add(newRequest);

                        // Send Emails
                        string[] otherUserEmails = getOtherUserEmails(user);
                        if (otherUserEmails.Any())
                        {
                            var otherUsersMessage = new Message(otherUserEmails, user.Email + " Has Scheduled Time Off", user.Email + " has scheduled time off for " + model.StartDate.ToShortDateString() + " thru " + model.EndDate.ToShortDateString() + ".<br><br>Please add it to your calendar.", "#", "");
                            await emailSender.SendEmailAsync(otherUsersMessage);
                        }

                        await emailTimeOffSummary(user, "scheduled time off for " + model.StartDate.ToShortDateString() + " thru " + model.EndDate.ToShortDateString() + ". ");

                        return(RedirectToAction("index"));
                    }
                    else
                    {
                        if (model.StartDate.Year == model.EndDate.Year)
                        {
                            int daysOff = WeekdayDifference(model.StartDate, model.EndDate, holidayRepository);
                            if (model.EndDate.Year == DateTime.Now.Year)
                            {
                                if (user.VacationDaysLeft >= daysOff)
                                {
                                    user.VacationDaysLeft -= daysOff;
                                    user.VacationDaysUsed += daysOff;

                                    Request newRequest = new Request
                                    {
                                        ApplicationUserID = model.ApplicationUserID,
                                        StartDate         = model.StartDate,
                                        EndDate           = model.EndDate,
                                        SpecialCase       = "Standard Personal/Vacation"
                                    };
                                    requestRepository.Add(newRequest);

                                    // Send Emails
                                    string[] otherUserEmails = getOtherUserEmails(user);
                                    if (otherUserEmails.Any())
                                    {
                                        var otherUsersMessage = new Message(otherUserEmails, user.Email + " Has Scheduled Time Off", user.Email + " has scheduled time off for " + model.StartDate.ToShortDateString() + " thru " + model.EndDate.ToShortDateString() + ".<br><br>Please add it to your calendar.", "#", "");
                                        await emailSender.SendEmailAsync(otherUsersMessage);
                                    }

                                    await emailTimeOffSummary(user, "scheduled time off for " + model.StartDate.ToShortDateString() + " thru " + model.EndDate.ToShortDateString() + ". ");

                                    return(RedirectToAction("index"));
                                }
                                else
                                {
                                    ModelState.AddModelError("", "You do not have enough Vacation Days Left for this request. Please shorten your request or talk to Arif.");
                                }
                            }
                            else
                            {
                                if (user.NextYearVacationDaysLeft > daysOff)
                                {
                                    user.NextYearVacationDaysLeft -= daysOff;
                                    user.NextYearVacationDaysUsed += daysOff;

                                    Request newRequest = new Request
                                    {
                                        ApplicationUserID = model.ApplicationUserID,
                                        StartDate         = model.StartDate,
                                        EndDate           = model.EndDate,
                                        SpecialCase       = "Standard Personal/Vacation"
                                    };
                                    requestRepository.Add(newRequest);

                                    // Send Emails
                                    string[] otherUserEmails = getOtherUserEmails(user);
                                    if (otherUserEmails.Any())
                                    {
                                        var otherUsersMessage = new Message(otherUserEmails, user.Email + " Has Scheduled Time Off", user.Email + " has scheduled time off for " + model.StartDate.ToShortDateString() + " thru " + model.EndDate.ToShortDateString() + ".<br><br>Please add it to your calendar.", "#", "");
                                        await emailSender.SendEmailAsync(otherUsersMessage);
                                    }

                                    await emailTimeOffSummary(user, "scheduled time off for " + model.StartDate.ToShortDateString() + " thru " + model.EndDate.ToShortDateString() + ". ");

                                    return(RedirectToAction("index"));
                                }
                                else
                                {
                                    ModelState.AddModelError("", "You do not have enough Vacation Days Left for this request. Please shorten your request or talk to Arif.");
                                }
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Request cannot span multiple years. Please make two seperate requests; one for this year and another for next year.");
                        }
                    }
                }
            }
            return(View());
        }
        /// <summary>
        /// ذخیره موقت درخواست به همراه پروفایل و دانشجو و شخص
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        public Tuple <bool, string> AddorUpdateRequest(RequestModel requestModel)
        {
            try
            {
                var student = _studentRepository.Where(s => s.StudentNumber == requestModel.StudentNumber).FirstOrDefault() ?? new Student();
                student.StudentNumber  = requestModel.StudentNumber;
                student.FieldofStudyId = requestModel.FieldofStudyId;
                //student.Grade = requestModel.Grade;
                //student.MilitaryServiceStatus = requestModel.MilitaryServiceStatus;

                var profile = _profileRepository.Where(p => p.NationalCode == requestModel.NationalCode).FirstOrDefault() ?? new Profile
                {
                    Name         = requestModel.Name,
                    Family       = requestModel.Family,
                    NationalCode = requestModel.NationalCode,
                    //Gender = requestModel.Gender
                };

                var request = _requestRepository.Find(i => i.Id == requestModel.Id) ?? new Request();
                request.RequestType            = requestModel.RequestType;
                request.NumberofRemainingUnits = requestModel.NumberofRemainingUnits;
                request.NumberofSpentUnits     = requestModel.NumberofSpentUnits;
                request.RequestStatus          = requestModel.RequestStatus;
                request.Description            = requestModel.Description;

                long personId = 0;
                if (profile.PersonId == 0)
                {
                    Person person = new Person
                    {
                        Profile = profile,
                        Student = student
                    };
                    _personRepository.Add(person);
                    personId = person.Id;
                }
                else
                {
                    personId         = profile.PersonId;
                    student.PersonId = profile.PersonId;
                    _studentRepository.AddOrUpdate(s => s.PersonId, student);
                }

                if (request.Id > 0)
                {
                    _requestRepository.Update(request);
                }
                else
                {
                    var member = _memberMasterRepository.Where(m => m.Active).FirstOrDefault();
                    request.PersonId = personId;
                    if (member != null)
                    {
                        request.MemberMasterId = member.Id;
                    }
                    _requestRepository.Add(request);
                }
                _unitOfWork.SaveChanges();
                return(new Tuple <bool, string>(true, "عملیات ثبت به درستی انجام شد"));
            }
            catch (Exception exception)
            {
                return(new Tuple <bool, string>(false, "خطا در ثبت درخواست"));
            }
        }
Exemple #23
0
 public Request Add(Request request)
 {
     return(_requestRepository.Add(request));
 }
 public void Create(Request request)
 {
     _requestRepository.Add(request);
 }
Exemple #25
0
 public async Task AddRequestAsync(Request request)
 {
     await Task.Run(() => _repository.Add(request));
 }
 public void Add(RequestEntity requestEntity)
 {
     _requestRepository.Add(requestEntity);
 }
Exemple #27
0
 public void AddRequest(Request request)
 {
     _requestRepository.Add(request);
 }
Exemple #28
0
 public Request Add(Request request)
 {
     request.RequestDate = DateTime.Now;
     request.Status      = 0;
     return(_requestRepository.Add(request));
 }
Exemple #29
0
 public long Add(Request entity)
 {
     return(_requestRepository.Add(entity));
 }