public bool SavePerformanceDocument(int GoalId, ObjectiveOfEmployeePerformance model, string Status, string UnitPercent) { var data = _db.EmployeePerformanceGoals.Where(x => x.Id == GoalId && x.Archived == false).FirstOrDefault(); if (data != null) { data.GoalStatus = Status; if (UnitPercent != null) { model.UnitPercent = UnitPercent; } data.LastModifiedDate = DateTime.Now; _db.SaveChanges(); } foreach (var item in model.DocumentList) { EmployeePerformanceGoalDocument docModel = new EmployeePerformanceGoalDocument(); docModel.PerformanceGoalId = GoalId; docModel.NewName = item.newName; docModel.OriginalName = item.originalName; docModel.UserIDCreatedBy = SessionProxy.UserId; docModel.Archived = false; docModel.CreatedDate = DateTime.Now; _db.EmployeePerformanceGoalDocuments.Add(docModel); _db.SaveChanges(); } return(true); }
//Save Performance Objective public bool SaveEmployeePerformanceObjective(ObjectiveOfEmployeePerformance model) { string inputFormat = "dd-MM-yyyy"; string outputFormat = "yyyy-MM-dd HH:mm:ss"; if (model.Id > 0) { var GoalData = _db.EmployeePerformanceGoals.Where(x => x.Id == model.Id && x.Archived == false).FirstOrDefault(); if (GoalData != null) { GoalData.EmployeePerformanceId = model.EmpPerformanceId; GoalData.EmployeePerformanceId = model.EmpPerformanceId; GoalData.GoalName = model.GoalName; GoalData.EmployeeId = model.EmployeeId; GoalData.GoalDescription = model.GoalDescription; if (model.DueDate != null) { var StartDateToString = DateTime.ParseExact(model.DueDate, inputFormat, CultureInfo.InvariantCulture); GoalData.DueDate = Convert.ToDateTime(StartDateToString.ToString(outputFormat)); } GoalData.Unit = model.UnitPercent; GoalData.LastModifiedDate = DateTime.Now; _db.SaveChanges(); } } else { EmployeePerformanceGoal goalModel = new EmployeePerformanceGoal(); goalModel.EmployeePerformanceId = model.EmpPerformanceId; goalModel.GoalName = model.GoalName; goalModel.EmployeeId = model.EmployeeId; goalModel.GoalDescription = model.GoalDescription; if (model.DueDate != null) { var StartDateToString = DateTime.ParseExact(model.DueDate, inputFormat, CultureInfo.InvariantCulture); goalModel.DueDate = Convert.ToDateTime(StartDateToString.ToString(outputFormat)); } goalModel.Unit = model.UnitPercent; goalModel.CreatedDate = DateTime.Now; goalModel.GoalValueX = 280; goalModel.GoalValueY = 205; goalModel.GoalStatus = "Open"; goalModel.Archived = false; _db.EmployeePerformanceGoals.Add(goalModel); _db.SaveChanges(); } return(true); }