public string SaveAssignedUserChange(string userid, string requestid)
        {
            try
            {
                var assignedUserChange = new AssignedUserChanges();

                assignedUserChange.UserId = Int32.Parse(userid);
                assignedUserChange.RequestId = Int32.Parse(requestid);
                assignedUserChange.DateCreated = DateTime.Now;

                _assignedUserChangesRepository.SaveAssignedUserChanges(assignedUserChange);

                // TODO: Move response to the constants
                return "Saved Assigned User Change - Success";
            }
            catch (Exception)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
        }
Beispiel #2
0
        public string SaveRequest(string requestsubject, 
            string requestdescription,
            string productid,
            string userid,
            string estimated,
            string logged)
        {
            try
            {
                var request = new Request();

                request.RequestSubject = requestsubject;
                request.RequestDescription = requestdescription;
                request.ProductId = Int32.Parse(productid);
                request.RequestReadyForArchive = false;

                if (estimated != null && estimated != String.Empty) {
                    request.Estimated = Int32.Parse(estimated);
                }

                if (logged != null && logged != String.Empty)
                {
                    request.Logged = Int32.Parse(logged);
                }

                request.RequestOpenDate = DateTime.Now;
                request.RequestClosedDate = DateTime.Now;
                request.DateCreated = DateTime.Now;

                // Save Request Status Changes entry
                request.RequestStatusChanges = new Collection<RequestStatusChanges>();
                var requestStatusChange = new RequestStatusChanges();
                requestStatusChange.RequestStatusId = (int)HelpDeskEnums.RequestStatus.Open;
                requestStatusChange.DateCreated = DateTime.Now;
                request.RequestStatusChanges.Add(requestStatusChange);

                // Save Assigned User Changes entry
                request.AssignedUserChanges = new Collection<AssignedUserChanges>();
                var assignedUserChange = new AssignedUserChanges();
                // TODO: Be defensive here, cannot cast any string!
                assignedUserChange.UserId = Int32.Parse(userid);
                assignedUserChange.DateCreated = DateTime.Now;
                request.AssignedUserChanges.Add(assignedUserChange);

                _requestRepository.SaveRequest(request);

                // TODO: Move response message to the constants file
                return "Saved Request - Success";
            }
            catch (Exception e)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
        }
 public void SaveAssignedUserChanges(AssignedUserChanges assignedUserChanges)
 {
     _context.AssignedUserChanges.Add(assignedUserChanges);
     _context.SaveChanges();
 }