Exemplo n.º 1
0
        public ActionResult Create(WorkRequestModel workRequest)
        {
            HttpCookie userCookie = HttpContext.Request.Cookies["UserCookie"] as HttpCookie;

            workRequest.OwnerName   = userCookie["UserName"];
            workRequest.CreatedDate = DateTime.Now;
            _WorkRequestRepository.SaveWorkRequest(workRequest);

            return(View("~/Views/WorkRequest/AllWorkRequests.cshtml", _WorkRequestRepository.GetAllWorkRequests()));
        }
Exemplo n.º 2
0
        public int Save(WorkRequestModel model)
        {
            var resData = model.GetWorkData();
            var workRes = new Work()
            {
                Id             = resData.Id,
                Title          = resData.Title,
                SourceTitle    = resData.SourceTitle,
                WorkTypeId     = resData.WorkType.Id,
                ReleaseYear    = resData.ReleaseYear,
                Doi            = resData.Doi,
                Issn           = resData.Issn,
                Essn           = resData.Essn,
                Isbn           = resData.Isbn,
                PublishedMonRK = resData.PublishedMonRK,
                AuthorId       = resData.Author.Id
            };

            Db.Works.InsertOrUpdate(workRes);
            Db.Complete();

            try
            {
                if (resData.CoAuthors != null && resData.CoAuthors.Count() > 0)
                {
                    var coAuth    = Db.Works.GetCoAuthorsByWorkId(workRes.Id);
                    var coAuthDel = coAuth.Where(ca => !resData.CoAuthors.Select(ca => ca.EmployeeId).Contains(ca.EmployeeId));
                    var coAuthIns = resData.CoAuthors.Where(ca => !coAuth.Select(a => a.EmployeeId).Contains(ca.EmployeeId));

                    Db.WorkCoAuthors.RemoveRange(coAuthDel);

                    var coAuthRes = coAuthIns.Select(ca => new WorkCoAuthor()
                    {
                        EmployeeId = ca.EmployeeId,
                        FromSU     = ca.FromSU,
                        WorkId     = workRes.Id
                    });

                    Db.WorkCoAuthors.InsertOrUpdateRange(coAuthRes);
                    Db.Complete();
                }
            }
            catch (Exception e)
            {
                Db.Dispose();

                throw new Exception(e.Message);
            }
            return(workRes.Id);
        }
Exemplo n.º 3
0
        public virtual ActionResult WorkRequestView()
        {
            PrismaServiceClient client = new PrismaServiceClient();

            RequestMessageGetWorkRequest request = new RequestMessageGetWorkRequest();

            request.Username = Environment.UserName;
            var response = client.GetWorkRequest(request);

            WorkRequest[] arr = response.WorkRequestList;

            WorkRequestModel model = new WorkRequestModel();

            model.WorkRequestList = new List <WorkRequest>(arr);

            return(View(model));
        }
Exemplo n.º 4
0
        public List <WorkRequestModel> GetAllWorkRequests()
        {
            List <WorkRequestModel> workRequests = new List <WorkRequestModel>();

            _WorkRequestConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString);
            using (_WorkRequestConnection)
            {
                SqlCommand command = new SqlCommand(_GetAllWorkRequests, _WorkRequestConnection);

                try
                {
                    _WorkRequestConnection.Close();
                    _WorkRequestConnection.Open();
                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        var workRequest = new WorkRequestModel
                        {
                            Id          = Convert.ToInt32(reader[0].ToString()),
                            OwnerName   = reader[1].ToString(),
                            Description = reader[2].ToString(),
                            Status      = reader[3].ToString(),
                            CreatedDate = Convert.ToDateTime(reader[4].ToString()),
                        };
                        workRequests.Add(workRequest);
                    }
                }
                catch (SqlException e)
                {
                    Console.Out.Write($"SQL Exception {e.Message}");
                    return(workRequests);
                }
                finally
                {
                    _WorkRequestConnection.Close();
                }
            }
            return(workRequests);
        }
Exemplo n.º 5
0
        public void SaveWorkRequest(WorkRequestModel workRequest)
        {
            SqlCommand command;

            _WorkRequestConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString);
            using (_WorkRequestConnection)
            {
                if ((workRequest.Id != 0))
                {
                    command = new SqlCommand(_UpdateWorkRequest, _WorkRequestConnection);
                    command.Parameters.AddWithValue("@Status", workRequest.Status);
                    command.Parameters.AddWithValue("@Description", workRequest.Description);
                }
                else
                {
                    command = new SqlCommand(_SaveWorkRequest, _WorkRequestConnection);
                    command.Parameters.AddWithValue("@OwnerName", workRequest.OwnerName);
                    command.Parameters.AddWithValue("@Status", workRequest.Status);
                    command.Parameters.AddWithValue("@Description", workRequest.Description);
                    command.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                }


                try
                {
                    _WorkRequestConnection.Open();
                    var reader = command.ExecuteReader();
                }
                catch (SqlException e)
                {
                    Console.Out.Write($"SQL Exception {e.Message}");
                    return;
                }
                finally
                {
                    _WorkRequestConnection.Close();
                }
            }
            return;
        }
Exemplo n.º 6
0
        public WorkRequestModel GetWorkRequest(int id)
        {
            WorkRequestModel workRequest = new WorkRequestModel();

            _WorkRequestConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString);
            using (_WorkRequestConnection)
            {
                SqlCommand command = new SqlCommand(_FindWorkRequestQuery, _WorkRequestConnection);
                command.Parameters.AddWithValue("@Id", id);

                try
                {
                    _WorkRequestConnection.Open();
                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        workRequest.Id          = Convert.ToInt32(reader[0].ToString());
                        workRequest.OwnerName   = reader[1].ToString();
                        workRequest.Description = reader[2].ToString();
                        workRequest.Status      = reader[3].ToString();
                        workRequest.CreatedDate = Convert.ToDateTime(reader[4].ToString());
                    }
                }
                catch (SqlException e)
                {
                    Console.Out.Write($"SQL Exception {e.Message}");
                    return(workRequest);
                }
                finally
                {
                    _WorkRequestConnection.Close();
                }
            }
            return(workRequest);
        }
Exemplo n.º 7
0
        public IActionResult Save([FromForm] WorkRequestModel model)
        {
            var res = _workService.Save(model);

            return(Ok(res));
        }
Exemplo n.º 8
0
 public ActionResult Save(WorkRequestModel workRequest)
 {
     _WorkRequestRepository.SaveWorkRequest(workRequest);
     return(View("~/Views/WorkRequest/AllWorkRequests.cshtml", _WorkRequestRepository.GetAllWorkRequests()));
 }