public void MarkPending() { StatusHistory.Add(OrderStatus.Create( Id, OrderStatusEnum.PENDING )); }
public async Task <IActionResult> PutStatusHistory(int id, StatusHistory statusHistory) { if (id != statusHistory.ID) { return(BadRequest()); } _context.Entry(statusHistory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StatusHistoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <StatusHistory> > PostStatusHistory(StatusHistory statusHistory) { _context.StatusHistory.Add(statusHistory); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStatusHistory", new { id = statusHistory.ID }, statusHistory)); }
private IList <StatusHistory> GetSampleStatusHistories() { var list = new StatusHistory[] { GetSampleStatusHistory( "01", new DateTime(2018, 5, 29, 10, 0, 0), DowntimeStatus.Started), GetSampleStatusHistory( "01", new DateTime(2018, 5, 29, 10, 0, 0), DowntimeStatus.Started ), GetSampleStatusHistory( "01", new DateTime(2018, 5, 29, 11, 0, 0), DowntimeStatus.Finished ), GetSampleStatusHistory( "01", new DateTime(2018, 5, 29, 12, 0, 0), DowntimeStatus.Started ), GetSampleStatusHistory( "01", new DateTime(2018, 5, 29, 13, 0, 0), DowntimeStatus.Finished ), }; return(list); }
public void MarkCanceled() { StatusHistory.Add(OrderStatus.Create( Id, OrderStatusEnum.CANCELED )); }
/// <summary> /// Returns false if application cannot be finalized due to all forms not being /// submitted /// </summary> /// <returns></returns> public virtual bool SubmitAndFinalize() { // There can be no unassigned forms foreach (var form in GetOrderedForms()) { if (form.IsRequired && !form.IsAssigned) { return(false); } } bool isIncomplete = HasStatus(EApplicationStatus.DeemedIncomplete); // There can be no warnings within the review. Also the application cannot be any step past submitted or resubmitted if (Review().Count > 0 || (!isIncomplete ? CurrentStatusLog.Status > EApplicationStatus.Submitted : CurrentStatusLog.Status >= EApplicationStatus.Resubmitted)) { return(false); } foreach (var form in GetOrderedForms()) { if (form is SignatureForm) { ((SignatureForm)form).Signatures.ForEach(x => x.IsSignatureFinalized = true); } } StatusHistory.Add(ApplicationStatusLogItem.FactoryCreate(isIncomplete ? EApplicationStatus.Resubmitted : EApplicationStatus.Submitted)); CanEdit = false; return(true); }
public void MarkComplete() { StatusHistory.Add(OrderStatus.Create( Id, OrderStatusEnum.COMPLETE )); }
public void MarkShipped() { StatusHistory.Add(OrderStatus.Create( Id, OrderStatusEnum.SHIPPED )); }
public static async Task <IActionResult> ReportStatus([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, TraceWriter log) { try { // Get Downtime Report using (var scope = Container.BeginLifetimeScope()) { var service = scope.Resolve <IDocumentService>(); var requestBody = new StreamReader(req.Body).ReadToEnd(); log.Info(requestBody); var report = JsonConvert.DeserializeObject <DowntimeReport>(requestBody); var targetService = await service.GetServiceAsync <Service>(report.ServiceId); //// Service current status update. if (targetService.CurrentStatus != report.Status) { targetService.CurrentStatus = report.Status; await service.UpdateDocumentAsync <Service>(targetService); var targetTeam = await service.GetServiceAsync <Team>(report.TeamId); targetTeam.UpdateService(targetService); await targetTeam.UpdateCurrentStateWithFunctionAsync(async() => { // This method is called when CurrentStatus is changing. var statusHistory = new StatusHistory { TeamId = targetTeam.id, Date = DateTime.UtcNow, // CurrentStatus is not updated in this time period // If the ServiceStatusTotal(GetTotalStatus) is true, then it means recorver from failure. // If it is false, then it means go to the failure state. Status = targetTeam.GetTotalStatus() ? DowntimeStatus.Finished : DowntimeStatus.Started }; await service.CreateDocumentAsync <StatusHistory>(statusHistory); }); await service.UpdateDocumentAsync <Team>(targetTeam); } // If status is failure, it write history. If you want to limit the number of inserting data, enable this. // Currently, I dump all data to the History collection. //if (!report.Status) // { await service.CreateDocumentAsync <History>(report.GetHistory()); // } return(new OkObjectResult("{'status': 'accepted'}")); } } catch (Exception e) { log.Error($"Report Status error: {e.Message}"); log.Error(e.StackTrace); return(new BadRequestObjectResult("{'status': 'error', 'message': '{" + e.Message + "'}")); } }
public StatusHistoryWindow(ObservableCollection <StatusChangeLog> statusChangeLog) { InitializeComponent(); if (IsWindowStateSet) { WindowState = _WindowState; if (_Left < SystemParameters.VirtualScreenWidth) { Left = _Left; } Top = _Top; Width = _Width; Height = _Height; } RefreshMaximizeRestoreButton(); Topmost = ApplicationOptions.IsAlwaysOnTopEnabled; _statusHistoryView = CollectionViewSource.GetDefaultView(statusChangeLog); _statusHistoryView.Filter = AddressFilter; StatusHistory.ItemsSource = _statusHistoryView; ((INotifyCollectionChanged)StatusHistory.Items).CollectionChanged += StatusHistory_CollectionChanged; // When initially displaying the window, automatically scroll to the most recent entry. if (StatusHistory.Items.Count > 0) { StatusHistory.ScrollIntoView(StatusHistory.Items[StatusHistory.Items.Count - 1]); } }
public void MarkFulfilled() { StatusHistory.Add(OrderStatus.Create( Id, OrderStatusEnum.FULFILLED )); }
public void AddStatusHistory(StatusHistory statusHistory) { //statusHistory.StatusOrder = Entities.StatusOrders.Where(t => t.id == statusHistory.idStatus).FirstOrDefault(); //statusHistory.Order = Entities.Orders.Where(x => x.id == statusHistory.idOrder).FirstOrDefault(); //statusHistory.Worker = Entities.Workers.Where(y => y.id == statusHistory.idWorker).FirstOrDefault(); //Entities.StatusHistories.Add(statusHistory); //Entities.SaveChanges(); }
public void Get_Down_Time_Basic() { // Normal case. Two sequential Downtime. var list = GetSampleStatusHistories(); var downtime = StatusHistory.GetServiceDowntimeTotal(list); Assert.AreEqual(TimeSpan.FromHours(2), downtime); }
public async Task <TimeSpan> GetDowntimeAsync(string teamId) { var statusHistories = await this.service.GetDocumentsAsync <StatusHistory>( (query) => { return(query.Where(f => f.TeamId == teamId)); } ); return(StatusHistory.GetServiceDowntimeTotal(statusHistories)); }
public void Complete(int Id) { var userId = User.Identity.GetUserId(); var service = _contex.Service.Where(m => m.ApplicationUserId == userId).SingleOrDefault(t => t.Id == Id); if (service == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } else { ////service.ApplicationUserId = User.Identity.GetUserId(); //MailMessage msg; //string emailId = string.Empty; //msg = new MailMessage(); //SmtpClient smtp = new SmtpClient(); ////sender email address //msg.From = new MailAddress("*****@*****.**"); ////Receiver email address //msg.To.Add("*****@*****.**"); ////email message subject //msg.Subject = "some string"; ////email message body //msg.Body = "Some string".Trim(); //msg.IsBodyHtml = true; //smtp.Credentials = new NetworkCredential("*****@*****.**", "zaq1@WSX"); //smtp.Port = 465; //smtp.Host = "smtp.poczta.onet.pl"; //smtp.EnableSsl = true; //smtp.Send(msg); if (service.StatusId != Status.ready) { service.StatusId = Status.ready; StatusHistory statushistory = new StatusHistory(); statushistory.ServiceId = service.Id; statushistory.StatusId = service.StatusId; statushistory.ChangeDate = DateTime.Now; _contex.StatusHistory.Add(statushistory); _contex.SaveChanges(); } //var serviceHistory = Mapper.Map<Service, ServiceHistory>(service); //serviceHistory.CompleteDate = DateTime.Now; //_contex.Service.Remove(service); //_contex.ServiceHistory.Add(serviceHistory); } }
public ActionResult Cancel(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var appointment = db.Appointments.Find(id); if (appointment == null) { return(HttpNotFound()); } //check the availability to cancel if ((appointment.DayofApp - DateTime.Today).TotalDays < 1) { return(RedirectToAction("MyAppointments", new { be = 1 })); } //cancelling var model = from r in db.AppointmentStatus where r.Name == "Cancelled" select r; appointment.AppointmentStatusId = model.First().Id; //put the change in status history StatusHistory s = new StatusHistory { AppointmentId = appointment.Id, StatusId = model.First().Id, Details = "before appointment " }; db.StatusHistories.Add(s); // make the slot taken = false var a = db.AvailableTimesLists.Find(appointment.Slot); a.Taken = false; db.Entry(a).State = EntityState.Modified; db.SaveChanges(); db.Entry(appointment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("MyAppointments")); }
public StatusHistoryWindow(ObservableCollection <StatusChangeLog> statusChangeLog) { InitializeComponent(); StatusHistory.ItemsSource = statusChangeLog; ((INotifyCollectionChanged)StatusHistory.Items).CollectionChanged += StatusHistory_CollectionChanged; // When initially displaying the window, automatically scroll to the most recent entry. if (StatusHistory.Items.Count > 0) { StatusHistory.ScrollIntoView(StatusHistory.Items[StatusHistory.Items.Count - 1]); } }
public void Get_Down_Time_Without_Finished() { var list = new List <StatusHistory>(); list.AddRange(GetSampleStatusHistories()); // This data is not finished. list.Add( GetSampleStatusHistory( "01", new DateTime(2018, 5, 29, 14, 0, 0), DowntimeStatus.Started )); var downtime = StatusHistory.GetServiceDowntimeTotal(list, new DateTime(2018, 5, 29, 15, 0, 0)); Assert.AreEqual(TimeSpan.FromHours(3), downtime); }
private async Task LogTransitionAsync(StateMachine <State, Trigger> .Transition arg) { var conditionalValue = await this.StateManager.TryGetStateAsync <StatusHistory>("statusHistory"); StatusHistory history; if (conditionalValue.HasValue) { history = StatusHistory.AddNewStatus(arg.Destination, conditionalValue.Value); } else { history = new StatusHistory(arg.Destination); } await this.StateManager.SetStateAsync <StatusHistory>("statusHistory", history); }
public static async Task <IActionResult> GetTeamsStatus([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req, TraceWriter log) { using (var scope = Container.BeginLifetimeScope()) { try { var service = scope.Resolve <DocumentService>(); // Get Openhack Start/End time. var openhack = await service.GetDocumentAsync <Openhack>(); // Get Team list var teams = await service.GetAllDocumentsAsync <Team>(); var list = new List <UptimeReport>(); foreach (var team in teams) { var histories = await service.GetDocumentsAsync <StatusHistory>( (query) => { return(query.Where(f => f.TeamId == team.Id)); }); var downtime = StatusHistory.GetServiceDowntimeTotal(histories); // TODO implement uptime and uppercent list.Add( new UptimeReport { Name = team.Name, Uptime = (int)openhack.GetUpTime(downtime).TotalHours, Uppercent = (int)openhack.GetTotalAvailavility(downtime), Point = 300 // No logic until now. } ); } var result = JsonConvert.SerializeObject(list); return(new OkObjectResult(result)); } catch (Exception e) { log.Error($"Get Team status error: {e.Message}"); log.Error(e.StackTrace); return(new BadRequestObjectResult("{'status': 'error', 'message': '{" + e.Message + "'}")); } } }
private void StatusHistory_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (StatusHistory.Items.Count > 0) { // Autoscroll to bottom only if no sorting has been set on any column (default) // or if timestamp column [1] is set to sort ascending. if (StatusHistory.Columns[1]?.SortDirection != ListSortDirection.Ascending) { for (int i = 0; i < StatusHistory.Columns.Count; ++i) { if (StatusHistory.Columns[i].SortDirection != null) { return; } } } StatusHistory.ScrollIntoView(StatusHistory.Items[StatusHistory.Items.Count - 1]); } }
private void LoadData(DataSet ds) { const int TBL_GENERAL = 0; const int TBL_LOCATIONS = 1; const int TBL_STATUS_HISTORY = 2; const int TBL_CURRENT_ICONS = 3; const int TBL_CURRENT_FILES = 4; const int TBL_CURRENT_ACCESS = 5; const int ROW_FIRST = 0; DataTable dtGeneral = ds.Tables[TBL_GENERAL]; if (dtGeneral.Rows.Count > 0) { DataRow dr = dtGeneral.Rows[ROW_FIRST]; // badge info Badge.BadgeID = (int)dr["BadgeID"]; Badge.BadgeNumber = (string)dr["BadgeNumber"]; Badge.BadgeColor = (string)dr["BadgeColor"]; Badge.WhenBecomesActive = (DateTime)dr["WhenBadgeBecomesActive"]; Badge.WhenExpires = (DateTime)dr["WhenBadgeExpires"]; Badge.BadgeStatus = (string)dr["BadgeStatus"]; // person info Person.NamePrefix = (string)dr["NamePrefixDescription"]; Person.FirstName = (string)dr["FirstName"]; Person.MiddleName = (string)dr["MiddleName"]; Person.LastName = (string)dr["LastName"]; Person.NameSuffix = (string)dr["NameSuffixDescription"]; // Unknown info Miscellaneous.FingerprintDate = Badge.WhenBecomesActive; Miscellaneous.PrintDate = Badge.WhenBecomesActive; Miscellaneous.PrintUser = "******"; // Company info Company.CompanyCode = (string)dr["CompanyCode"]; Company.CompanyID = (int)dr["CompanyID"]; Company.CorporationName = (string)dr["CorporationName"]; // Division info Division.DivisionID = (int)dr["DivisionID"]; Division.DivisionCode = (string)dr["DivisionCode"]; Division.DivisionName = (string)dr["DivisionName"]; if (dr.Table.Columns.Contains("DivisionTypeName")) { Division.DivisionTypeName = (string)dr["DivisionTypeName"]; } Division.JobRole = (string)dr["JobRoleDescription"]; } DataTable dtLocations = ds.Tables[TBL_LOCATIONS]; if (dtLocations.Rows.Count > 0) { foreach (DataRow row in dtLocations.Rows) { Locations.Add(new Location(row)); } SelectedLocation = Locations[0]; } DataTable dtStatusHistory = ds.Tables[TBL_STATUS_HISTORY]; StatusHistory.Clear(); if (dtStatusHistory.Rows.Count > 0) { foreach (DataRow row in dtStatusHistory.Rows) { StatusHistory.Add(new BadgeStatusPeriod(row)); } } DataTable dtCurrentIcons = ds.Tables[TBL_CURRENT_ICONS]; CurrentIcons.Clear(); if (dtCurrentIcons.Rows.Count > 0) { foreach (DataRow row in dtCurrentIcons.Rows) { CurrentIcons.Add(new BadgeIcon(row)); } } DataTable dtCurrentFiles = ds.Tables[TBL_CURRENT_FILES]; CurrentFiles.Clear(); if (dtCurrentFiles.Rows.Count > 0) { foreach (DataRow row in dtCurrentFiles.Rows) { CurrentFiles.Add(new BadgeFile(row)); } } /**** * else * { * CurrentFiles.Add(new BadgeFile("text file (54) (spoofed data)", "54", "text/plain")); * CurrentFiles.Add(new BadgeFile("pdf file (5) (spoofed data)", "5", "application/pdf")); * } */ DataTable dt = ds.Tables[TBL_CURRENT_ACCESS]; CurrentAccess.Clear(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { CurrentAccess.Add(new BadgeAccessCategory(row)); } } /*** * else * { * CurrentAccess.Add(new BadgeAccessCategory()); * CurrentAccess.Add(new BadgeAccessCategory()); * CurrentAccess.Add(new BadgeAccessCategory()); * CurrentAccess.Add(new BadgeAccessCategory()); * } */ }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as EpisodeOfCare; if (dest != null) { base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatus>)StatusElement.DeepCopy(); } if (StatusHistory != null) { dest.StatusHistory = new List <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent>(StatusHistory.DeepCopy()); } if (Type != null) { dest.Type = new List <Hl7.Fhir.Model.CodeableConcept>(Type.DeepCopy()); } if (Patient != null) { dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy(); } if (ManagingOrganization != null) { dest.ManagingOrganization = (Hl7.Fhir.Model.ResourceReference)ManagingOrganization.DeepCopy(); } if (Period != null) { dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy(); } if (Condition != null) { dest.Condition = new List <Hl7.Fhir.Model.ResourceReference>(Condition.DeepCopy()); } if (ReferralRequest != null) { dest.ReferralRequest = new List <Hl7.Fhir.Model.ResourceReference>(ReferralRequest.DeepCopy()); } if (CareManager != null) { dest.CareManager = (Hl7.Fhir.Model.ResourceReference)CareManager.DeepCopy(); } if (CareTeam != null) { dest.CareTeam = new List <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareCareTeamComponent>(CareTeam.DeepCopy()); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
public ActionResult Edit(Appointment app, FormCollection f) { string sts = f["sts"].ToString(); string patientstatename = f["PSED"]; //CHANGE STATE NAME TO NEW NAME if (patientstatename != null) { var x = db.PatientStates.Find(app.PatientStateId); x.StateName = patientstatename; } if (ModelState.IsValid) { int APPSTATid = int.Parse(sts); app.AppointmentStatusId = APPSTATid; StatusHistory s = new StatusHistory { StatusId = APPSTATid, AppointmentId = app.Id, Details = "Doctor" }; db.StatusHistories.Add(s); //check cancel before app date var cancel_Id = db.AppointmentStatus.Where(sa => sa.Name == "Cancelled").FirstOrDefault().Id; if (APPSTATid == cancel_Id && (app.DayofApp - DateTime.Today).TotalDays < 1) { SendEmailController e1 = new SendEmailController(); string S = app.TimeStart.GetDisplayName(); string Name = app.PatientState.Patient.UserName; string Email = app.PatientState.Patient.Email; var task = e1.SendEmail(S, Name, Email, "2"); // make the slot taken = false var a = db.AvailableTimesLists.Find(app.Slot); a.Taken = false; db.Entry(a).State = EntityState.Modified; db.SaveChanges(); db.Entry(app).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ClinicApps", new { id = app.ClinicId })); } //other status var Attended_Id = db.AppointmentStatus.Where(sa => sa.Name == "Attended").FirstOrDefault().Id; if (APPSTATid == Attended_Id) { var pat = db.Users.Find(app.PatientState.PatientId); var no = db.Appointments.Where(c => c.PatientState.PatientId == pat.Id && c.AppointmentStatusId != cancel_Id).ToList().Count; pat.Rate += 1 / no; db.Entry(pat).State = EntityState.Modified; db.SaveChanges(); db.Entry(app).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ClinicApps", new { id = app.ClinicId })); } var NAttended_Id = db.AppointmentStatus.Where(sa => sa.Name == "Not Attended").FirstOrDefault().Id; if (APPSTATid == NAttended_Id) { var pat = db.Users.Find(app.PatientState.PatientId); var no = db.Appointments.Where(c => c.PatientState.PatientId == pat.Id && c.AppointmentStatusId != cancel_Id).ToList().Count; pat.Rate -= 1 / no; db.Entry(pat).State = EntityState.Modified; db.SaveChanges(); db.Entry(app).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ClinicApps", new { id = app.ClinicId })); } //cancel after db.Entry(app).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ClinicApps", new { id = app.ClinicId })); } return(View()); }
public EnrichedStatusHistory(StatusHistory statusHistory) { this.StatusHistory = statusHistory; }
public ActionResult Create(DateTime date, TimeSlots time, int Id, int time1, FormCollection f) { // check if patient has already make an appointment with same clinic in same day string currentUserId = User.Identity.GetUserId(); var clinic = db.Clinics.Find(Id); var c = db.Appointments.Where(x => x.PatientState.PatientId == currentUserId && x.ClinicId == Id && x.DayofApp == date).ToList(); if (c.Count > 1) { ViewBag.Result = "You have applied before !"; return(View()); } // check if he has a previous Patient state with same name with same category string patientstatename = f["pa"]; List <Appointment> check; var ExpatientStates = db.PatientStates.Where(x => x.PatientId == currentUserId && x.StateName == patientstatename).ToList(); var st1 = ExpatientStates.FirstOrDefault(); check = db.Appointments.Where(u => u.PatientStateId == st1.Id && u.Clinic.CategoryId == clinic.CategoryId).ToList(); //if (check.Count == 0) PatientState p; // new patientstate if not there one if (ExpatientStates.Count == 0 || check.Count == 0) { p = new PatientState { PatientId = currentUserId, StateName = patientstatename, InProgress = true, StartTime = date }; db.PatientStates.Add(p); db.SaveChanges(); } //get the old one else { var qqqqq = from e in check where e.Clinic.CategoryId == clinic.CategoryId select e.PatientStateId; int id = qqqqq.FirstOrDefault(); p = ExpatientStates.FirstOrDefault(e => e.Id == id); } #region old way to get ava //Days st = Days.Saturday; //Days q=Days.Saturday; //for (int i = 1; i < 8; i++) //{ // if (q.GetDisplayName() == date.DayOfWeek.ToString()) { st = q; } // q = (Days)i; //} //get the time slot to make it unavailable : 1) get the day //var day= from r in db.DayLists // where r.ClinicId == Id && (r.DayName==st) // select r; // var x = db.AvailableTimesLists.TakeWhile(t => t.DayListId == day.First().Id && t.Slot_start == time); //var tim = from t in db.AvailableTimesLists // where t.DayListId == day && t.Slot_start == time // select t; // var a = db.AvailableTimesLists.Where(s => s.DayListId == day.FirstOrDefault().Id && s.Slot_start == time).FirstOrDefault(); //var a = tim.FirstOrDefault(); #endregion // get time slot of this day to make it taken var a = db.AvailableTimesLists.Find(time1); a.Taken = true; db.Entry(a).State = EntityState.Modified; db.SaveChanges(); //make an appointment with this tSlot with status "scheduled" var model = from r in db.AppointmentStatus where r.Name == "Scheduled" select r; Appointment app = new Appointment { ClinicId = Id, AppointmentStatusId = model.First().Id, DayofApp = date, PatientStateId = p.Id, TimeStart = time, Slot = time1 }; db.Appointments.Add(app); db.SaveChanges(); StatusHistory s = new StatusHistory { StatusId = model.First().Id, AppointmentId = app.Id, Details = "first" }; db.StatusHistories.Add(s); db.SaveChanges(); return(RedirectToAction("MyAppointments")); #region commented //if (clinicid == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } //d.ClinicId = int.Parse(clinicid); //var c = db.Clinics.Find(d.ClinicId); //if (c.DayLists.ToList().Find(q => q.DayName == d.DayName) != null) { return RedirectToAction("YourclinicDaylist"); } //if (ModelState.IsValid) //{ // db.DayLists.Add(d); // for (int i = (int)c.StartTime; i < (int)c.EndTime; i++) // { // AvailableTimesList availableTimes = new AvailableTimesList { DayListId = d.Id, Taken = false, Slot_start = (TimeSlots)i }; // db.AvailableTimesLists.Add(availableTimes); // } // db.SaveChanges(); // return RedirectToAction("YourclinicDaylist"); //} #endregion }
public ActionResult Save(Service service) { var userId = User.Identity.GetUserId(); if (service.Id != 0) { if (!ModelState.IsValid) { var viewmodel = new ServiceStatusViewModel { Service = service, Status = _contex.Status.ToList() }; return(View("ServiceFormEdit", viewmodel)); } var serviceInDb = _contex.Service.Where(m => m.ApplicationUserId == userId).SingleOrDefault(s => s.Id == service.Id); if (serviceInDb == null) { return(HttpNotFound()); } else { service.AddDate = serviceInDb.AddDate; service.Key = serviceInDb.Key; service.ApplicationUserId = serviceInDb.ApplicationUserId; if (serviceInDb.StatusId != service.StatusId) { StatusHistory statushistory = new StatusHistory(); statushistory.ServiceId = service.Id; statushistory.StatusId = service.StatusId; statushistory.ChangeDate = DateTime.Now; _contex.StatusHistory.Add(statushistory); _contex.SaveChanges(); } Mapper.Map(service, serviceInDb); _contex.SaveChanges(); } return(RedirectToAction("Index")); } else { var key = new Key(); service.Key = key.GenerateKey(); service.AddDate = DateTime.Now; service.ApplicationUserId = User.Identity.GetUserId(); service.StatusId = Status.unready; service.Priority = false; if (!ModelState.IsValid) { return(View("ServiceForm", service)); } _contex.Service.Add(service); _contex.SaveChanges(); StatusHistory statushistory = new StatusHistory(); statushistory.ServiceId = service.Id; statushistory.StatusId = service.StatusId; statushistory.ChangeDate = DateTime.Now; _contex.StatusHistory.Add(statushistory); _contex.SaveChanges(); return(RedirectToAction("Index")); } }
/// <summary> /// Returns whether a certain status has been logged /// </summary> /// <param name="status"></param> /// <returns></returns> public bool HasStatus(EApplicationStatus status) { return(StatusHistory.Any(x => x.Status == status)); }
public void MarkIncomplete() { StatusHistory.Add(OrderStatus.Create( Id )); }