Ejemplo n.º 1
0
 public static AppointmentViewModel ToViewModel(this AppointmentModel x)
 {
     if (x == null)
     {
         return(new AppointmentViewModel());
     }
     return(new AppointmentViewModel
     {
         Id = x.Id,
         CreatedBy = x.CreatedBy,
         UpdatedBy = x.UpdatedBy,
         CreatedOn = x.CreatedOn,
         UpdatedOn = x.UpdatedOn,
         IsDeleted = x.IsDeleted,
         IsActive = x.IsActive,
         AppointmentDate = x.AppointmentDate,
         Note = x.Note,
         CancellationReason = x.CancellationReason,
         isAppointmentDone = x.isAppointmentDone,
         EndTime = x.EndTime,
         StartTime = x.StartTime,
         Status = x.Status,
         IsCancel = x.IsCancel,
         ToUserId = x.ToUserId,
         FromUserId = x.FromUserId,
         FromUser = x.FromUser != null?x.FromUser.ToViewModel() : null,
                        ToUser = x.ToUser != null?x.ToUser.ToViewModel() : null,
                                     CreatedUser = x.CreatedUser != null?x.CreatedUser.ToViewModel() : null,
                                                       UpdatedUser = x.UpdatedUser != null?x.UpdatedUser.ToViewModel() : null,
     });
 }
Ejemplo n.º 2
0
        //Get model for Create New Appointment
        public IActionResult Create()
        {
            ViewBag.FormName = "Appointment";
            if (!(bool)SharedData.isAppointmentMenuAccessible)
            {
                return(AccessDeniedView());
            }
            var model = new AppointmentModel();

            model.AppointmentDate = DateTime.UtcNow;

            //23/09/19 aakansha
            model.AvailableHospitals.Add(new SelectListItem {
                Text = "Select Hospitals", Value = "0"
            });

            foreach (var c in _hospitalServices.GetAllHospital())
            {
                model.AvailableHospitals.Add(new SelectListItem
                {
                    Text     = _encryptionService.DecryptText(c.HospitalName),
                    Value    = c.Id.ToString(),
                    Selected = c.Id == model.HospitalId
                });
            }
            return(View(model));
        }
Ejemplo n.º 3
0
    public void SetData(List <AppointmentRuleVo> appointmentRuleVos, AppointmentModel appointmentModel)
    {
        //参考GamePlay并且看看CMD的协议
        //第一步,读取拉下来的恋爱对象数据
        //第二步点击不同的角色进入不同的日记UI。
        int[] ids =
        {
            PropConst.CardEvolutionPropChi, PropConst.CardEvolutionPropQin, PropConst.CardEvolutionPropTang,
            PropConst.CardEvolutionPropYan
        };

        //要优化一下算法了,因为有三重循环在,效率非常低下!
        if (ids.Length <= 4)
        {
            for (int i = 0; i < ids.Length; i++)
            {
                //_rolesContent.GetChild(i).gameObject.Show();
                Image image = _rolesContent.GetChild(i).GetComponent <Image>();
                image.alphaHitTestMinimumThreshold = 0.1f;
                GameObject redpoint = _rolesContent.GetChild(i).Find("RedPoint").gameObject;

                PointerClickListener.Get(_rolesContent.GetChild(i).gameObject).parameter = ids[i];//appointmentRuleVos[i];
                PointerClickListener.Get(_rolesContent.GetChild(i).gameObject).onClick   = GoToJournal;

                //GetTargetData.先获取到AppointmentRule,然后在判断是否有userAppintment在其中,然后每个appointment是否有可解锁的。
                //最好的办法就是做一个全局的可解锁条件和全部通关未拍照的条件。

                var  roleAppointmentRule = appointmentModel.GetTargetData(ids[i]);
                bool showredpoint        = false;
                foreach (var ruleVo in roleAppointmentRule)
                {
                    var userappointment = appointmentModel.GetUserAppointment(ruleVo.Id);
                    //这个要抽出来做成全局通用的判断!!
                    if (userappointment == null)
                    {
                        continue;
                    }
                    //有这张卡并且有红点的时候有两种情况:1.没有激活这张卡。2.有可以解锁的关卡。3.有新的卡
                    foreach (var v in ruleVo.ActiveCards)
                    {
                        showredpoint = appointmentModel.NeedSetRedPoint(userappointment, v);
                        //Debug.LogError("WHY NO SHOW?");
                        if (showredpoint)
                        {
                            break;
                        }
                    }
                    if (showredpoint)
                    {
                        break;
                    }
                }
                redpoint.gameObject.SetActive(showredpoint);
            }
        }
        else
        {
            Debug.LogError(appointmentRuleVos.Count);
        }
    }
Ejemplo n.º 4
0
        public ActionResult Save(AppointmentModel appointment)
        {
            if (!ModelState.IsValid)
            {
                return(View("AppointmentForm", new AppointmentViewModel()
                {
                    Appointment = appointment,
                    Medics = _usersRepo.GetMedicsForAppointment(),
                    Pets = _petsRepo.GetPetsByOwner(ApplicationHelper.LoggedUser.Id)
                }));
            }
            try
            {
                _appointmentsRepo.AddOrUpdate(appointment);
            }
            catch (Exception e)
            {
                return(HttpNotFound());
            }


            if (appointment.Id == 0)
            {
                return(RedirectToAction("Index", "Appointment"));
            }

            return(RedirectToAction("Show", new { id = appointment.Id }));
        }
Ejemplo n.º 5
0
        public ActionResult Edit(int id)
        {
            var appointment = AppointmentBO.GetById(id);

            if (appointment == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }
            appointment.Attendees = AppointmentBO.GetUsers(appointment.Id);

            var model = new AppointmentModel
            {
                Id              = appointment.Id,
                Title           = appointment.Title,
                Description     = appointment.Description,
                StartAndEndDate = appointment.StartDate.ToString(Helper.FormatDateTime) + " - " + appointment.EndDate.ToString(Helper.FormatDateTime),
                Attendees       = appointment.Attendees != null?appointment.Attendees.Select(u => u.Id).ToList() : new List <int>()
            };

            ViewBag.Count = AppointmentBO.CountCommentAccepted(model.Id);

            ViewBag.DisplayReject = CurrentUser.Id != appointment.CreateBy &&
                                    AppointmentBO.CommentCheckExisted(model.Id, CurrentUser.Id) == null;

            ViewBag.DisplaySave = CurrentUser.Id == appointment.CreateBy;

            PreparingData();
            return(View("Create", model));
        }
        public void EmailBooking(AppointmentModel app)
        {
            try
            {
                Email_Api       emailApi     = new Email_Api();
                Appointment_Api aptms        = new Appointment_Api();
                var             apppointment = aptms.GetAllAppointments().Where(a => a.appointment_ID == app.appointment_ID).First();
                var             patients     = emailApi.GetPatientsAppointments();

                Admin_Api adminApi   = new Admin_Api();
                var       patDetails = (adminApi.GetAllPatients()).Where(p => p.pid == apppointment.paitent_ID).First();

                MailMessage mailMessage = new MailMessage("*****@*****.**", patDetails.emailID);
                // Specify the email body
                mailMessage.Body = "Dear Patient you have booked appointment with Doctor " + app.doctorName +
                                   " Appointment ID is " + app.appointment_ID + " appointment time is " + app.timings;
                mailMessage.Subject = "Success Booking";
                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                smtpClient.Credentials = new System.Net.NetworkCredential()
                {
                    UserName = "******",
                    Password = "******"
                };
                smtpClient.EnableSsl = true;
                smtpClient.Send(mailMessage);
            }
            catch (Exception ex)
            {
                Utils.Logging(ex, 2);
            }
        }
Ejemplo n.º 7
0
        //view  screen
        public ActionResult PatientAppointment(int patientId = 0)
        {
            if (Convert.ToString(Session["key"]) != "patient")
            {
                return(RedirectToAction("Login", "Home"));
            }

            AppointmentModel appModel = new AppointmentModel();
            Admin_Api        adminApi = new Admin_Api();
            var model = adminApi.GetAllDoctor().ToArray();

            List <DoctorDropDown> items = new List <DoctorDropDown>();

            foreach (var m in model)
            {
                appModel.doctorDetails.Add(m);
                items.Add(new DoctorDropDown
                {
                    Value = (m.pid),
                    Text  = m.firstName
                });
            }
            appModel.doctorDropDown = items;

            return(View("~/Views/Patient/PatientBookAppointment.cshtml", appModel));
        }
Ejemplo n.º 8
0
        public JsonResult CreateAppointment(string employeeID, string clinicId, string poliId, string doctorId, string necesity, string AppointmentDate, string MCUPackage)
        {
            var response = new AppointmentResponse();
            var _model   = new AppointmentModel
            {
                AppointmentDate = CommonUtils.ConvertStringDate2Datetime(AppointmentDate),
                ClinicID        = Convert.ToInt64(clinicId),
                EmployeeID      = Convert.ToInt64(employeeID),
                DoctorID        = Convert.ToInt64(doctorId),
                PoliID          = Convert.ToInt64(poliId),
                RequirementID   = Convert.ToInt16(necesity),
                MCUPakageID     = Convert.ToInt64(MCUPackage),
            };

            if (Session["UserLogon"] != null)
            {
                _model.Account = (AccountModel)Session["UserLogon"];
            }
            var request = new AppointmentRequest
            {
                Data = _model
            };

            response = new AppointmentValidator(_unitOfWork).Validate(request);

            return(Json(new { Status = response.Status, Message = response.Message }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 9
0
        private IEnumerable <AppointmentModel> WeeklySchedule(string pageSource)
        {
            //_logger.Info("WeeklySchedule(pageSource)");
            var weeklySchedule = new List <AppointmentModel>();

            var doc = new HtmlDocument();

            doc.LoadHtml(pageSource);

            HtmlNodeCollection days = doc.DocumentNode.SelectNodes("//*[@isnode='true']");

            foreach (HtmlNode day in days)
            {
                string aday      = day.ChildNodes[1].InnerText;
                string aschedule = day.ChildNodes[3].InnerText;

                DateTime nday = DateTime.Parse(Regex.Match(aday, @"(\w+\,\s\w+\s\d+\,\s\d+)").Value);

                string   schedule  = Regex.Replace(aschedule, @"&nbsp;", "^");
                string[] nschedule = schedule.Split('^');

                foreach (string item in nschedule)
                {
                    if (item != string.Empty)
                    {
                        try
                        {
                            string[] nitem = Regex.Split(item, @"((\d+:\d\d\s\w+)(\s-\s)(\d+:\d\d\s\w+))");

                            var appt = new AppointmentModel();
                            appt.Date = nday;
                            if (!Regex.IsMatch(nitem[0], @"\w+\d+\:\d+\s\w+\s\-\s\d+\/\d+\/\d+\s\d+\:\d+\s\w+"))
                            {
                                appt.Subject   = nitem[0];
                                appt.StartTime = DateTime.ParseExact(nday.Date.ToString("MM/dd/yyyy") + " " + nitem[2],
                                                                     "MM/dd/yyyy h:mm tt", CultureInfo.InvariantCulture);
                                appt.EndTime = DateTime.ParseExact(nday.Date.ToString("MM/dd/yyyy") + " " + nitem[4],
                                                                   "MM/dd/yyyy h:mm tt", CultureInfo.InvariantCulture);
                            }
                            else
                            {
                                appt.Subject   = Regex.Match(nitem[0], @"[a-zA-Z]+").Value;
                                appt.StartTime = DateTime.ParseExact(nday.Date.ToString("MM/dd/yyyy") + " 8:00 AM",
                                                                     "MM/dd/yyyy h:mm tt", CultureInfo.InvariantCulture);
                                appt.EndTime = DateTime.ParseExact(nday.Date.ToString("MM/dd/yyyy") + " 8:00 PM",
                                                                   "MM/dd/yyyy h:mm tt", CultureInfo.InvariantCulture);
                            }

                            weeklySchedule.Add(appt);
                        }
                        catch (Exception)
                        {
                            // Days off, including weekends, or if there is any funky formatting thats one off.
                        }
                    }
                }
            }
            return(weeklySchedule);
        }
 public dateLookup_AppointmentViewModel(AppointmentModel appointment, CustomerModel customerData)
 {
     id           = appointment.id;
     customer     = new dateLookup_CustomerViewModel(customerData);
     aptstartTime = appointment.aptstartTime;
     aptendTime   = appointment.aptendTime;
     status       = appointment.status;
 }
 /// <summary>
 /// Loads the Appointment Details View and fill the fields with the values from the given AppoinmentModel
 /// </summary>
 /// <param name="model">Appointment to edit</param>
 public void LoadAppointment(AppointmentModel model)
 {
     model = SelectedAppointment;
     AppointmentsDetailsView = new AppointmentDetailsViewModel(model, AvailableDogs);
     Items.Add(AppointmentsDetailsView);
     ManageAppointmentsIsVisible      = false;
     AppointmentsDetailsViewIsVisible = true;
 }
Ejemplo n.º 12
0
 public void SaveAppointment(AppointmentModel appointmentModel)
 {
     using (var context = new MCContext())
     {
         context.AppointmentModels.Add(appointmentModel);
         context.SaveChanges();
     }
 }
Ejemplo n.º 13
0
        public async Task <IActionResult> SetAppointmentCheckIn([FromBody] AppointmentModel appointment)
        {
            appointment.Status        = Convert.ToInt32(AppointmentStatus.CheckedIn);
            appointment.WorkflowState = Convert.ToInt32(AppointmentStatus.CheckedIn);
            var token = HttpContext.Request.Headers["Authentication"];

            return(await this.exceptionHandler.SendResponse(this, this.context.UpdateStatusWithNotification(appointment, NotificationEvent.CHECKIN, token)));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Get the basic patient information for appointment creation
        /// </summary>
        /// <param name="patientId"></param>
        /// <returns></returns>
        public AppointmentModel GetAppointmentCreationInformation(int patientId)
        {
            AppointmentModel model = new AppointmentModel {
                Patient = _patientManager.GetPatientById(patientId)
            };

            return(model);
        }
        // GET: Appointments/Create
        public ActionResult Create()
        {
            AppointmentModel CreatelistDisponibilities = new AppointmentModel();

            CreatelistDisponibilities.Disponibilities = sap.GetDisponibilities(Global.globalIdDoctor);

            return(View(CreatelistDisponibilities));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// List Cell Tap Event
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public void ListListener(object sender, ItemTappedEventArgs e)
        {
            AppointmentModel appointment = (AppointmentModel)e.Item;
            var appointmentPage          = new AppointmentDetailPage();

            appointmentPage.BindingContext = appointment;
            Navigation.PushAsync(appointmentPage, true);
        }
Ejemplo n.º 17
0
 public long AppointmentInsert(AppointmentModel model)
 {
     using (var dbctx = DbContext)
     {
         var id = dbctx.AppointmentInsert(model.CreatedBy, model.AppointmentDate, model.Note, model.StartTime, model.EndTime, model.ToUserId, model.FromUserId, model.Status).FirstOrDefault();
         return(Convert.ToInt64(id ?? 0));
     }
 }
Ejemplo n.º 18
0
        public AppointmentSyncModel Create(AppointmentItem appointmentItem)
        {
            var desktopAppointment = new AppointmentModel
            {
                Body                       = appointmentItem.Body,
                Title                      = appointmentItem.Subject,
                AllDayEvent                = appointmentItem.AllDayEvent,
                Categories                 = appointmentItem.Categories,
                Companies                  = appointmentItem.Companies,
                CreationTime               = appointmentItem.CreationTime,
                Duration                   = appointmentItem.Duration,
                End                        = appointmentItem.End,
                GlobalAppointmentID        = appointmentItem.GlobalAppointmentID,
                IsOnlineMeeting            = appointmentItem.IsOnlineMeeting,
                IsRecurring                = appointmentItem.IsRecurring,
                Location                   = appointmentItem.Location,
                Mileage                    = appointmentItem.Mileage,
                NetMeetingAutoStart        = appointmentItem.NetMeetingAutoStart,
                NetMeetingDocPathName      = appointmentItem.NetMeetingDocPathName,
                NetMeetingOrganizerAlias   = appointmentItem.NetMeetingOrganizerAlias,
                NetMeetingServer           = appointmentItem.NetMeetingServer,
                NetShowUrl                 = appointmentItem.NetShowURL,
                NoAging                    = appointmentItem.NoAging,
                OptionalAttendees          = appointmentItem.OptionalAttendees,
                Organizer                  = appointmentItem.Organizer,
                ReminderMinutesbeforeStart = appointmentItem.ReminderMinutesBeforeStart,
                ReminderOverrideDetault    = appointmentItem.ReminderOverrideDefault,
                ReminderPlaySound          = appointmentItem.ReminderPlaySound,
                ReminderSet                = appointmentItem.ReminderSet,
                ReminderSoundFile          = appointmentItem.ReminderSoundFile,
                ReplyTime                  = appointmentItem.ReplyTime,
                RequiredAttendees          = appointmentItem.RequiredAttendees,
                Resources                  = appointmentItem.Resources,
                ResponseRequested          = appointmentItem.ResponseRequested,
                Start                      = appointmentItem.Start,
                Subject                    = appointmentItem.Subject,
                UnRead                     = appointmentItem.UnRead
            };

            desktopAppointment.Recipients = new List <RecipientModel>();
            foreach (Recipient recipient in appointmentItem.Recipients)
            {
                if (recipient != null)
                {
                    desktopAppointment.Recipients.Add(new RecipientModel
                    {
                        Name  = recipient.Name,
                        Email = recipient.Address
                    });
                }
            }

            var appointmentSyncModel = new AppointmentSyncModel();

            appointmentSyncModel.Data = desktopAppointment;

            return(appointmentSyncModel);
        }
Ejemplo n.º 19
0
 public async Task<IHttpActionResult> UpdateAppointment(int id, AppointmentModel appointmentModel)
 {
     string user = User.Identity.GetUserName();
     Lead result = await _leadService.UpdateAppointment(id, user, appointmentModel);
     return Ok(new
     {
         data = result
     });
 }
        //Delete Appointment
        public JsonResult BookAppointment(AppointmentModel App)
        {
            bool status = false;

            status = appointment.BookDoctor(App, status);
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Ejemplo n.º 21
0
        public ViewResult MakeBooking(AppointmentModel appt)
        {
            if (ModelState.IsValid)
            {
                return(View("Completed", appt));
            }

            return(View());
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Doctors the name tapped.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 private void DoctorNameTapped(object sender, EventArgs arg)
 {
     try {
         AppointmentModel appointment = (AppointmentModel)BindingContext;
         MessagingCenter.Send <AppointmentCell, AppointmentModel>(this, Constants.Constants.MESSEGE_CENTER_OPEN_DOCTOR_PAGE, appointment);
     } catch (Exception e) {
         System.Diagnostics.Debug.WriteLine(" Exception occured in DoctorNameTapped, with exception stack trace {0}", e.ToString());
     }
 }
Ejemplo n.º 23
0
        public IActionResult Create()
        {
            AppointmentModel       appointmentModel = new AppointmentModel();
            IEnumerable <Activity> activities       = activityService.GetAll();

            appointmentModel.Activities = activities.ToList();

            return(View(appointmentModel));
        }
Ejemplo n.º 24
0
        public Clue Create(AppointmentModel value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(this.Create(EntityType.Calendar.Event, value.Object.Id.UniqueId));
        }
        public async Task <OperationResult> Create(AppointmentModel appointmentModel)
        {
            using (var transaction = await _dbContext.Database.BeginTransactionAsync())
            {
                try
                {
                    if (appointmentModel.ExpireAt == null || appointmentModel.StartAt == null ||
                        appointmentModel.ExpireAt <= appointmentModel.StartAt || appointmentModel.StartAt <= DateTime.UtcNow)
                    {
                        return(new OperationResult(
                                   false,
                                   _appointmentLocalizationService.GetString("AppointmentDateNotCorrect")));
                    }

                    var appointment = new Entities.Appointment
                    {
                        CreatedAt       = DateTime.UtcNow,
                        CreatedByUserId = UserId,
                        ExpireAt        = appointmentModel.ExpireAt,
                        StartAt         = appointmentModel.StartAt,
                        Info            = appointmentModel.Info,
                        Description     = appointmentModel.Description,
                        Title           = appointmentModel.Title,
                        ColorHex        = appointmentModel.ColorHex,
                        RepeatEvery     = appointmentModel.RepeatEvery,
                        RepeatType      = appointmentModel.RepeatType,
                        RepeatUntil     = appointmentModel.RepeatUntil,
                        SdkeFormId      = appointmentModel.eFormId
                    };

                    await appointment.Create(_dbContext);

                    foreach (var siteUid in appointmentModel.SiteUids)
                    {
                        var appointmentSite = new Entities.AppointmentSite()
                        {
                            AppointmentId    = appointment.Id,
                            MicrotingSiteUid = siteUid
                        };
                        await appointmentSite.Create(_dbContext);
                    }

                    transaction.Commit();
                    return(new OperationResult(
                               true,
                               _appointmentLocalizationService.GetString("AppointmentCreatedSuccessfully")));
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    Trace.TraceError(e.Message);
                    return(new OperationResult(false,
                                               _appointmentLocalizationService.GetString("ErrorWhileCreatingAppointment")));
                }
            }
        }
Ejemplo n.º 26
0
        public AppointmentModel GetById(int id)
        {
            appointment      entity = this._repository.GetById(id);
            AppointmentModel model  = this.ConvertEntityToModel(entity);

            model.EmployeeList        = (List <EmployeeModelConcise>) this._appointmentEmployeeService.ConvertEntityListToEmployeeModelConciseList(entity.appointment_employee);
            model.HitchayvutList      = (List <HitchayvutModel>) this._appointmentHitchayvutService.ConvertEntityListToHitchayvutModelList(entity.appointment_hitchayvut);
            model.AppointmentTestList = (List <AppointmentTestModel>) this._appointmentTestService.ConvertEntityListToModelList(entity.appointment_test);
            return(model);
        }
Ejemplo n.º 27
0
        public AppointmentModel PrepareAppointmentModel(AppointmentModel model, Appointment department)
        {
            if (department != null)
            {
                //fill in model values from the entity
                model = model ?? department.ToModel <AppointmentModel>();
            }

            return(model);
        }
Ejemplo n.º 28
0
        public void Test_AppointmentModelExists()
        {
            var sut = new AppointmentModel();
            AppointmentModel sut1 = new AppointmentModel();

            var actual = sut;

            Assert.IsType <AppointmentModel>(actual);
            Assert.NotNull(actual);
        }
Ejemplo n.º 29
0
        private string GetAppointmentConfirmationInformation(AppointmentModel appointment)
        {
            string appointmentText = string.Format("You currently have a {0} appointment scheduled for {1} with {2}.  Your appointment was confirmed on {3}",
                                                   appointment.Subject,
                                                   appointment.AppointmentStartTime.ToString("f", CultureInfo.CurrentCulture),
                                                   appointment.AgentName,
                                                   appointment.AppointmentConfirmationDate.ToString("d", CultureInfo.CurrentCulture));

            return(appointmentText);
        }
Ejemplo n.º 30
0
        public int AppointmentPending(AppointmentModel appointmentModel)
        {
            int result = 0;

            PractitionerBusiness businessLayer = new PractitionerBusiness();

            result = businessLayer.AppointmentPending(appointmentModel);

            return(result);
        }
        public bool IsClientAvailable(AppointmentModel proposedAppt)
        {
            //NOTE: I chose to assume a client would be free so long that two appts did not start at the same time.
            //If I were to develop this further, services could have a defined time allotments that I would take into consideration in the provider's availability.

            return(!_readOnlySpaAppContext.Appointments
                   .Any(appt => appt.AppointmentTime == proposedAppt.AppointmentTime &&
                        appt.ClientId == proposedAppt.ClientId &&
                        appt.Id != proposedAppt.Id));
        }
Ejemplo n.º 32
0
 public ActionResult Index(AppointmentModel model)
 {
     if (ModelState.IsValid)
     {
         return View(model);
     }
     else
     {
         return View();
     }
 }
Ejemplo n.º 33
0
        public ActionResult UpdateExpectedDate(int pk, string name, string value)
        {
            GATE_MaterialRequest request = DB.GATE_MaterialRequest.Find(pk);
            Employee concernedEmployee = request.ConcernedEmployee;
            Employee manager = request.ConcernedEmployee.Manager;
            Employee lom = LoggedUser;

            //Update date of all components
            foreach (GATE_ComponentRequest component in request.ComponentRequests)
            {
                component.CurrentSuggestion.DeliveryDate = Convert.ToDateTime(value);
            }

            //Create appointment
            DateTime deliveryDay = Convert.ToDateTime(value).Date;

            string deliveryDate = (!request.ExpectedDate.Equals(DateTime.MinValue) && request.ExpectedDate != null ? request.ExpectedDate.Value.Date.ToShortDateString() : "No date defined");
            string officeName = (request.Office != null ? request.Office.Name : (request.Address != null ? request.Address.Complement : "No destination defined"));
            string linkToOrder = Url.Action("Index", "OrderDetails", new { id = request.MaterialRequestId }, Request.Url.Scheme);

            MessageTemplateOptions template = new MessageTemplateOptions("NewDeliveryDateExpected",
                new
                {
                    managerName = manager.Name,
                    managerEmail = manager.Email,
                    lomEmail = lom.Email,
                    concernedEmployeeName = concernedEmployee.Name,
                    officeName,
                    deliveryDate,
                    linkToOrder,
                    orderNumber = request.MaterialRequestId
                });
            template.ApplicationName = "AmarisGate";
            template.UserId = LoggedUser.EmployeeId;

            AppointmentModel appointment = new AppointmentModel(deliveryDay, deliveryDay.AddHours(24))
            {
                IsAllDayEvent = true,
                Categories = new List<string> { "AmarisGate", "Project" },
                Location = officeName
            };

            request.AddAppointment(template, appointment);

            if (name == null)
                name = "ExpectedDate";

            return XEditableUpdate(DB.GATE_MaterialRequest, pk, name, value);
        }
Ejemplo n.º 34
0
 //
 // GET: /Appointment/
 public ActionResult Index()
 {
     var model = new AppointmentModel();
     return View(model);
 }