public async Task <ActionResult <ChangeRequestData> > PostChangeRequestData(ChangeRequestData changeRequestData)
        {
            _context.ChangeRequestData.Add(changeRequestData);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetChangeRequestData", new { id = changeRequestData.CRDataId }, changeRequestData));
        }
        public async Task <IActionResult> PutChangeRequestData(int id, ChangeRequestData changeRequestData)
        {
            if (id != changeRequestData.CRDataId)
            {
                return(BadRequest());
            }

            _context.Entry(changeRequestData).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChangeRequestDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public void AddRequest(ChangeRequestData Request)
 {
     using (var db = new AppSalesMan2DbContext())
     {
         changeRequests.Add(Request);
         SaveChanges();
     }
 }
        public async Task <ActionResult <ChangeRequest> > PostChangeRequest(CreateChangeRequest param)
        {
            ChangeRequest cr = new ChangeRequest
            {
                ProjectId         = param.ProjectId,
                UserId            = param.UserId,
                ChangeRequestName = param.ChangeRequestName,
                Requester         = param.Requester,
                ApprovalReqDate   = param.ApprovalReqDate,
                ApprovedDate      = param.ApprovedDate,
                Status            = param.Status,
            };

            _context.ChangeRequest.Add(cr);
            await _context.SaveChangesAsync();

            if (param.Status != 0)
            {
                cr.CustomId = CustomId(param.ProjectId, 0);

                if (param.Status == 1 && cr.RaisedDate == null)
                {
                    cr.RaisedDate = DateTime.Now;
                }
            }

            foreach (ChangeRequestData x in param.ChangeRequestData)
            {
                ChangeRequestData crd = new ChangeRequestData
                {
                    ChangeRequestId = cr.ChangeRequestId,
                    CRCategoryId    = x.CRCategoryId,
                    Title           = x.Title,
                    Description     = x.Description
                };
                _context.ChangeRequestData.Add(crd);
            }

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetChangeRequest", new { id = cr.ChangeRequestId }, cr));
        }
示例#5
0
        public int ChangePassword(string password)
        {
            ChangeRequestData data = new ChangeRequestData(SelectedAccount.email, SelectedAccount.password, password);

            try
            {
                string json = RequestHandler.RequestChangePassword(data);

                if (json != "OK")
                {
                    return(-1);
                }
            }
            catch
            {
                return(-2);
            }

            SelectedAccount.password = password;
            launcherConfig.Password  = password;
            JsonHandler.SaveLauncherConfig(launcherConfig);
            return(1);
        }
示例#6
0
        public int ChangeEmail(string email)
        {
            ChangeRequestData data = new ChangeRequestData(SelectedAccount.email, SelectedAccount.password, email);

            try
            {
                string json = RequestHandler.RequestChangeEmail(data);

                if (json != "OK")
                {
                    return(-1);
                }
            }
            catch
            {
                return(-2);
            }

            launcherConfig.Email  = email;
            SelectedAccount.email = email;
            JsonHandler.SaveLauncherConfig(launcherConfig);
            return(1);
        }
示例#7
0
 public static string RequestChangePassword(ChangeRequestData data)
 {
     return(request.Send("/launcher/profile/change/password", Json.Serialize(data)));
 }
示例#8
0
 public static string RequestChangeEmail(ChangeRequestData data)
 {
     return(request.Send("/launcher/profile/change/email", Json.Serialize(data)));
 }
        public async Task <IActionResult> PutChangeRequest(int id, CreateChangeRequest param)
        {
            if (id != param.ChangeRequestId)
            {
                return(BadRequest());
            }

            var cr = await _context.ChangeRequest.FindAsync(id);

            cr.ProjectId         = param.ProjectId;
            cr.UserId            = param.UserId;
            cr.ChangeRequestName = param.ChangeRequestName;
            cr.Requester         = param.Requester;
            cr.ApprovalReqDate   = param.ApprovalReqDate;
            cr.ApprovedDate      = param.ApprovedDate;
            cr.Status            = param.Status;

            if (param.Status != 0)
            {
                if (cr.CustomId == null)
                {
                    cr.CustomId = CustomId(cr.ProjectId, 1);
                }

                if (param.Status == 1 && cr.RaisedDate == null)
                {
                    cr.RaisedDate = DateTime.Now;
                }
            }
            else
            {
                cr.CustomId = param.CustomId;
            }

            var crd = await _context.ChangeRequestData
                      .Where(x => x.ChangeRequestId == id)
                      .ToListAsync();

            foreach (var x in crd)
            {
                _context.ChangeRequestData.Remove(x);
            }

            foreach (ChangeRequestData x in param.ChangeRequestData)
            {
                ChangeRequestData crd2 = new ChangeRequestData
                {
                    ChangeRequestId = cr.ChangeRequestId,
                    CRCategoryId    = x.CRCategoryId,
                    Title           = x.Title,
                    Description     = x.Description
                };
                _context.ChangeRequestData.Add(crd2);
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChangeRequestExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(cr));
        }
示例#10
0
 public ChangeRequestModel Map(ChangeRequestData changeRequest)
 {
     return(_Mapper.Map <ChangeRequestModel>(changeRequest));
 }