public async Task <bool> EditProject(Project project) { var proj = await _context.Projects.FindAsync(project.Id); proj.Description = project.Description; proj.Name = project.Name; proj.Type = project.Type; proj.StartDate = project.StartDate; proj.DeliveryDate = project.DeliveryDate; proj.LastUpdate = DateTime.Now; proj.ContractValue = project.ContractValue; proj.EstimetedBudget = project.EstimetedBudget; proj.EmployeesId = project.ProjectManagerId; proj.CustomersId = project.CustomerId; proj.Status = project.Status; proj.Cost = project.Cost + project.ExtraCost; if (project.Status == "Closed") { proj.ClosedDate = DateTime.Now; } _context.Entry(proj).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <int> AddEmp(EmpModel empModel) { var job = await _context.Job.FindAsync(empModel.JobTitleId); var newEmp = new Employees() { EmpFName = empModel.EmpFName, EmpLName = empModel.EmpLName, Index = empModel.UserName, Email = empModel.Email, JobTitleId = empModel.JobTitleId, Address = empModel.Address, PMId = 0, Dob = empModel.Dob, WorkSince = empModel.WorkSince, Mobile = empModel.Mobile.HasValue ? empModel.Mobile.Value : 0, ProfilePhoto = empModel.PhotoURL, Gender = empModel.Gender, Status = empModel.Status, Designation = job.JobName, CasualAllocated = job.Casual, AnnualAllocated = job.Annual, MedicalAllocated = job.Medical, ShortLeaveAllocated = job.ShortLeaves, HalfLeaveAllocated = job.HalfDays, FromDate = empModel.WorkSince.AddMonths(1), Todate = empModel.WorkSince.AddMonths(1).AddYears(1) }; await _context.Employees.AddAsync(newEmp); await _context.SaveChangesAsync(); return(newEmp.EmpId); }
public async Task <int> AddCustomer(Customer customer) { var NewCustomer = new Customers { Name = customer.Name, Address = customer.Address, ContactNo = customer.ContactNo, Email = customer.Email }; await _context.Customers.AddAsync(NewCustomer); await _context.SaveChangesAsync(); return(NewCustomer.Id); }
public async Task <int> AddNewCustomer(CustomerModel model) { var newCustomer = new PreSalesCustomers() { name = model.name, address = model.address, contactNumber = model.contactNumber, emailAddress = model.emailAddress }; await _context.PreSalesCustomers.AddAsync(newCustomer); await _context.SaveChangesAsync(); return(newCustomer.Id); }
public async Task <IActionResult> SendMessage( int roomId, string message, [FromServices] EmpStoreContext ctx) { var Message = new Message { ChatId = roomId, Text = message, Name = User.Identity.Name, Timestamp = DateTime.Now }; ctx.Messages.Add(Message); await ctx.SaveChangesAsync(); await room.Clients.Group(roomId.ToString()) .SendAsync("RecieveMessage", new { Text = Message.Text, Name = Message.Name, Timestamp = Message.Timestamp.ToString("dd/MM/yyy hh:mm:ss") }); return(Ok()); }
public async Task <bool> Updatejob(JobModel jobModel) { var job = await _context.Job.FindAsync(jobModel.JobId); job.JobName = jobModel.JobName; job.Casual = jobModel.Casual.HasValue ? jobModel.Casual.Value : 0; job.Annual = jobModel.Annual.HasValue ? jobModel.Annual.Value : 0; job.Medical = jobModel.Medical.HasValue ? jobModel.Medical.Value : 0; job.ShortLeaves = jobModel.ShortLeaves.HasValue ? jobModel.ShortLeaves.Value : 0; job.HalfDays = jobModel.HalfDays.HasValue ? jobModel.HalfDays.Value : 0; _context.Entry(job).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <int> AddNewTask(PreTaskModel model) { var newTask = new PreSalesTasks() { Number = model.Number, Description = model.Description, Duration = model.Duration, StartDate = model.StartDate, EndDate = model.EndDate, Priority = model.Priority, Assignee = model.Assignee, ProjectsID = model.ProjectsID, IsAssigned = false }; await _context.PreSalesTasks.AddAsync(newTask); await _context.SaveChangesAsync(); return(newTask.Id); }
public async Task <int> AddNewBudget(BudgetModel model) { var newBudget = new PreSalesBudget() { Id = model.Id, Actual = model.Actual, LbHou = model.LbHou, LbRate = model.LbRate, MtUnit = model.MtUnit, MtunitPr = model.MtunitPr, Under = model.Under, cost = model.cost, BudgetCost = model.BudgetCost, ProjectsID = model.ProjectsID }; await _context.PreSalesBudget.AddAsync(newBudget); await _context.SaveChangesAsync(); return(newBudget.Id); }
public async Task <int> AddLeave(LeaveApplyModel LeaveApplyModel) { var leaveApply = new LeaveApply() { LeaveType = LeaveApplyModel.LeaveType, Startdate = LeaveApplyModel.Startdate, EndDate = LeaveApplyModel.EndDate, Reason = LeaveApplyModel.Reason, EmpId = LeaveApplyModel.EmpId, AppliedDate = DateTime.Now, NoOfDays = LeaveApplyModel.NoOfDays, Status = "Waiting for Recommendation", Visible = "Show", PdfURL = LeaveApplyModel.PdfURL }; await _context.LeaveApply.AddAsync(leaveApply); await _context.SaveChangesAsync(); return(leaveApply.LeaveApplyId); }
public async Task <int> AddNew(Payment model) { var newCollection = new Payment() { ProjectId = model.ProjectId, Amount = model.Amount, Comment = model.Comment, Date = DateTime.Now }; await _context.Payments.AddAsync(newCollection); await _context.SaveChangesAsync(); return(newCollection.Id); }
public async Task <IActionResult> CreatePrivateRoom(string userId) { var chat = new Chat { Name = "Private", Type = ChatType.Private }; chat.Users.Add(new ChatUser { UserId = userId }); chat.Users.Add(new ChatUser { UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value }); _ctx.Chats.Add(chat); await _ctx.SaveChangesAsync(); return(RedirectToAction("Chat", new { id = chat.Id })); }
public async Task <int> AddNewCollection(CollectionModel model) { var newCollection = new PreSalescollection() { Description = model.Description, value = model.value, ProjecstID = model.ProjectsID, }; await _context.PreSalescollection.AddAsync(newCollection); await _context.SaveChangesAsync(); return(newCollection.Id); }
public async Task <int> AddNewDocument(DocumentModel model) { var newDocument = new Document() { ScopeDocumentUrl = model.ScopeDocumentUrl, ActionPlanUrl = model.ActionPlanUrl, TimePlanUrl = model.TimePlanUrl, ProjectsID = model.ProjectsID }; await _context.PreSalesDocument.AddAsync(newDocument); await _context.SaveChangesAsync(); return(newDocument.ID); }
public async Task <int> AddRequest(AttendenceModel attendenceModel) { var attendence = new Attendence() { Date = attendenceModel.Date, InTime = attendenceModel.InTime, OutTime = attendenceModel.OutTime, TotalHours = attendenceModel.TotalHours, BreakingHours = attendenceModel.BreakingHours, WorkingHours = attendenceModel.WorkingHours, Explanation = attendenceModel.Explanation, EmpId = attendenceModel.EmpId, Type = "Manual", AppliedDate = DateTime.UtcNow, Status = "Pending" }; await _context.Attendence.AddAsync(attendence); await _context.SaveChangesAsync(); return(attendence.AttendenceId); }
//finish public async Task <int> AddNewProject(ProjectModel model) { var newProject = new PreSalesProjects() { startDate = model.startDate, Description = model.Description, Title = model.Title, endDate = model.EndDate, ProjectType = model.ProjectType, value = model.value, ProjectBudget = model.ProjectBudget, CustomersId = model.CustomersId, projectManagerId = model.projectManagerId, preProjectState = true, }; await _context.PreSalesProjects.AddAsync(newProject); await _context.SaveChangesAsync(); return(newProject.ID); }
public async Task <bool> AddCost(int id, DateTime Start, DateTime End) { var taskInfo = await _context.Tasks.FindAsync(id); int projectId = taskInfo.ProjectsId; int empId = taskInfo.EmployeesId; var emp = await _context.Employees.FindAsync(empId); Double rate = await _context.Salarys.Where(x => x.Designation == emp.Designation).Select(y => y.HourlyRate).FirstOrDefaultAsync(); Double hours = (End.ToLocalTime() - Start.ToLocalTime()).TotalHours; var proj = await _context.Projects.FindAsync(projectId); proj.Cost = proj.Cost + (rate * hours); proj.FinalizedTasks = proj.FinalizedTasks + 1; var collections = _context.PreSalescollection.Where(x => x.ProjecstID == projectId).ToList(); double cumilativeCollectionValue = collections[0].value; try { for (int i = 0; i < collections.Count; i++) { if (cumilativeCollectionValue < proj.Cost && cumilativeCollectionValue + collections[i + 1].value < proj.Cost) { Utility.EmailSender.BudgetRemainder(); break; } if (i != 0) { cumilativeCollectionValue = cumilativeCollectionValue + collections[i].value; } } } catch (Exception) { throw; } _context.Entry(proj).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <int> InTimeMark(TimeTrackerModel timeTrackerModel) { var timeTracker = new TimeTracker() { Date = DateTime.Now.Date, InTime = DateTime.Now, TotalHours = 0, WorkingHours = 0, BreakingHours = 0, EmpId = timeTrackerModel.EmpId, Status = "Work", Inlocation = timeTrackerModel.Inlocation, Inlatitude = timeTrackerModel.Inlatitude, InLongitude = timeTrackerModel.InLongitude }; await _context.TimeTracker.AddAsync(timeTracker); await _context.SaveChangesAsync(); var info = _context.MarkAttendence.SingleOrDefault(x => (x.EmpId == timeTrackerModel.EmpId) && (x.Date == DateTime.Now.Date)); if (info == null) { var markAttendence = new MarkAttendence() { Date = DateTime.Now.Date, InTime = DateTime.Now, OutTime = null, TotalHours = 0, EmpId = timeTrackerModel.EmpId, Type = "Auto", Status = "Absent", EmailSent = false }; await _context.MarkAttendence.AddAsync(markAttendence); await _context.SaveChangesAsync(); } else { info.InTime = DateTime.Now; info.Type = "Auto"; info.Status = "Absent"; info.EmailSent = false; _context.Entry(info).State = EntityState.Modified; await _context.SaveChangesAsync(); } return(timeTracker.TrackId); }
public async Task <int> AddVal(int TaskId, int id, int Val, int EmpId) { var task = await _context.Tasks.FindAsync(TaskId); var project = await _context.Projects.FindAsync(task.ProjectsId); var GivenEmp = await _context.Employees.FindAsync(EmpId); var Work = new WorkQualityModel() { TaskId = TaskId, EmployeesId = id, Quality = Val, GivenEmpId = EmpId, ProjectName = project.Name, TaskName = task.Name, GivenEmp = GivenEmp.EmpFName + " " + GivenEmp.EmpLName }; await _context.WorkQuality.AddAsync(Work); await _context.SaveChangesAsync(); return(Work.Id); }