public IActionResult EditConfirm([FromForm] DoctorAddForm request)
        {
            #region EditDoctorInfo
            List <LangDTO> langs  = new ServiceNode <object, List <LangDTO> >(_fc).GetClient("/api/lang/all").Data;
            DoctorAdd      doctor = new DoctorAdd();
            doctor.DoctorLevel = request.DoctorLevel;
            doctor.Sex         = request.Sex;
            doctor.ServiceId   = request.ServiceId;
            doctor.Name        = request.Name;
            doctor.LevelType   = request.LevelType;
            List <InfoStr> infostrs = new List <InfoStr>();
            List <IstanbulNsApp.Areas.Admin.Models.Phone> phones = new List <IstanbulNsApp.Areas.Admin.Models.Phone>();
            for (int i = 0; i < langs.Count; i++)
            {
                infostrs.Add(new InfoStr
                {
                    LangId = langs[i].Id,
                    Info   = request.InfoStrs[i]
                });
            }
            for (int i = 0; i < request.Phones.Count; i++)
            {
                phones.Add(new IstanbulNsApp.Areas.Admin.Models.Phone
                {
                    PhoneNumber = request.Phones[i]
                });
            }
            string pictureName = string.Empty;
            if (request.Picture != null)
            {
                if (request.ExistedPicture != null)
                {
                    FileManager.Delete(request.ExistedPicture, "DoctorPictures");
                }
                pictureName = FileManager.IFormSaveLocal(request.Picture, "DoctorPictures");
            }
            doctor.InfoStrs = infostrs;
            doctor.Picture  = pictureName;

            ///  DoctorInfos

            DoctorsInfo dcInfo = new DoctorsInfo();
            dcInfo.Location         = request.Location;
            dcInfo.Phones           = phones;
            dcInfo.WorkTimeFromDate = request.WorkTimeFromDate;
            dcInfo.WorkTimeToDate   = request.WorkTimeToDate;
            dcInfo.WorkTimeToTime   = request.WorkTimeToTime;
            dcInfo.WorkTimeFromTime = request.WorkTimeFromTime;
            dcInfo.Email            = request.Email;
            doctor.DoctorsInfos     = dcInfo;
            var req = new ServiceNode <DoctorAdd, object>(_localizer, _fc).PostClient(doctor, $"/api/doctors/update/{request.Id}");
            if (req.IsCatched == 1)
            {
                return(RedirectToAction("Edit"));
            }
            #endregion
            TempData["R_Message_Doc"] = "Dəyişdirildi";
            return(RedirectToAction("Doctors", "Home"));
        }
Beispiel #2
0
        public async Task <IActionResult> ConfirmReal([FromBody] OnlineQuery request)
        {
            #region FunctionBody
            bool existed = await _db.OnlineQueries.AnyAsync(
                a =>
                a.QueryDate == request.QueryDate &&
                a.IsDeleted == 0 &&
                a.IsSchedule == 1);

            if (existed)
            {
                return(BadRequest(new ReturnErrorMessage(errortype: (int)ErrorTypes.Errors.ExistedTime, message: "This Time is exist by other user")));
            }
            Doctor dcBase = await _db.Doctors.FirstOrDefaultAsync(a => a.Id == request.DoctorId);

            DoctorsInfo doctor = await _db.DoctorsInfos.FirstOrDefaultAsync(a => a.DoctorId == request.DoctorId);

            if (
                doctor.WorkTimeFromDate > (int)request.QueryDate.DayOfWeek ||
                doctor.WorkTimeToDate < (int)request.QueryDate.DayOfWeek
                )

            {
                return(BadRequest(new ReturnErrorMessage(errortype: (int)ErrorTypes.Errors.NotAllowedTime, message: "This Time not registered by Doctor")));
            }
            try
            {
                request.ServeDate  = DateTime.Now;
                request.IsSchedule = 1;
                request.IsOnline   = 0;
                request.Price      = dcBase.Price;
                await _db.OnlineQueries.AddAsync(request);
            }
            catch (Exception x)
            {
                return(BadRequest(new ReturnErrorMessage(errortype: (int)ErrorTypes.Errors.Internal, message: x.Message, code: 500)));
            }
            await _db.SaveChangesAsync();

            return(Ok(new ReturnMessage()));

            #endregion
        }