예제 #1
0
        public string CreateProject(ProjectModel project)
        {
            var response = string.Empty;
            if (String.IsNullOrEmpty(project.Code) || String.IsNullOrEmpty(project.Name) || project.Budget == 0)

                return response = "All fields are required...";

                try
                {
                    var createNew = entityProjects.Projects.Add(new Project
                    {
                        Name = project.Name,
                        Code = project.Code,
                        Remarks = project.Remarks,
                        Budget = project.Budget
                    });
                    entityProjects.SaveChanges();
                    response = "Successfully Added";
                }
                catch (Exception ex)
                {
                    _logger.Fatal(string.Format("{0} | {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, ex));
                    response = "Exception Error";
                }

            return response;
        }
예제 #2
0
        public Object UpdateProjectResponse(ProjectModel project)
        {
            var status = projectorDAL.UpdateProject(project);

            var data = new { status };

            return data;
        }
예제 #3
0
 public ActionResult CreateProject(ProjectModel project)
 {
     var projectSvc = new ProjectorService();
     Object data = projectSvc.CreateProjectResponse(project);
     return Json(data, JsonRequestBehavior.AllowGet);
 }
예제 #4
0
        public string UpdateProject(ProjectModel project)
        {
            var response = string.Empty;
            if (String.IsNullOrEmpty(project.Code) || String.IsNullOrEmpty(project.Name) || project.Budget == 0)

                return response = "All fields are required...";

            try
            {
                var updateProject = entityProjects.Projects.Where(a=> a.ProjectId == project.ProjectId).FirstOrDefault();

                    updateProject.Name = project.Name;
                    updateProject.Code = project.Code;
                    updateProject.Remarks = project.Remarks;
                    updateProject.Budget = project.Budget;

                entityProjects.SaveChanges();
                response = "Successfully Updated";
            }
            catch (Exception ex)
            {
                _logger.Fatal(string.Format("{0} | {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, ex));
                response = "Exception Error";
            }

            return response;
        }