private ProcessResult VerifeyModel(DoctorPhone d)
        {
            ProcessResult result = new ProcessResult();

            if (d.Phone.Length == 0)
            {
                result.Errors.Add("Telefon numarası kısmı boş bırakılamaz");
            }

            result.Result = result.Errors.Count == 0 ? Extensions.BLLResult.Verified : Extensions.BLLResult.NotVerified;

            return(result);
        }
        public Extensions.DataBaseResult Insert(DoctorPhone newDoctorPhone)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                ctx.DoctorPhones.Add(newDoctorPhone);

                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
        public ProcessResult Update(DoctorPhone newInfoDoctorPhone)
        {
            ProcessResult result = VerifeyModel(newInfoDoctorPhone);

            if (result.Result != Extensions.BLLResult.Verified)
            {
                return(result);
            }

            DAL.Extensions.DataBaseResult insert = _doctorPhoneDal.Update(newInfoDoctorPhone);

            switch (insert)
            {
            case DAL.Extensions.DataBaseResult.AlreadyFound:
                result.Result = Extensions.BLLResult.AlreadyFound;
                result.Errors.Add(Extensions.AlreadyFoundString(newInfoDoctorPhone.Phone));
                break;

            case DAL.Extensions.DataBaseResult.Error:
                result.Result = Extensions.BLLResult.InnerException;
                result.Errors.Add(Extensions.InnerException);
                break;

            case DAL.Extensions.DataBaseResult.Success:
                result.Result = Extensions.BLLResult.Success;
                result.Errors.Add(Extensions.SuccessProcess);
                break;

            case DAL.Extensions.DataBaseResult.ServerDisable:
                result.Result = Extensions.BLLResult.ServerDisable;
                result.Errors.Add(Extensions.ServerDisable);
                break;

            case DAL.Extensions.DataBaseResult.Referanced:
                break;

            case DAL.Extensions.DataBaseResult.NotFound:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(result);
        }
        public Extensions.DataBaseResult Delete(int id)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                DoctorPhone doctorPhone = ctx.DoctorPhones.FirstOrDefault(d => d.Id == id);

                if (doctorPhone == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }
                ctx.DoctorPhones.Remove(doctorPhone);
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Beispiel #5
0
        public Extensions.DataBaseResult Update(DoctorPhone newInfoDoctorPhone)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                DoctorPhone doctorPhone = ctx.DoctorPhones.FirstOrDefault(d => d.Id == newInfoDoctorPhone.Id);

                if (doctorPhone == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                doctorPhone.Phone = newInfoDoctorPhone.Phone;
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }