Exemplo n.º 1
0
        public void SaveApointMent(ReferalApointment model)
        {
            var repo = new AllRepository <ReferalApointment>();

            if (model.Id == 0)
            {
                repo.InsertModel(model);
            }
            else
            {
                repo.UpdateModel(model);
            }
            repo.Save();
        }
Exemplo n.º 2
0
        public string SaveApointMentDetail(ReferalApointment model)
        {
            var result = new DataServiceResult <ReferalApointment>();

            try
            {
                //ToDo:Model state check
                //JsonConvert.DeserializeObject<ReferalApointment>(model.ToString());
                if (ModelState.IsValid)
                {
                    if (model.ApointmentDate == null && model.ApointmentDate < DateTime.Now.Date)
                    {
                        result.Success = false;
                        ModelState.AddModelError("ApointmentDate", "Apontment date should be greter then current date");
                    }
                    else
                    {
                        model.CreatedOn = DateTime.Now.Date;
                        siterepo.SaveApointMent(model);

                        result.Success = true;
                        result.Value   = model;
                    }
                }
                else
                {
                    result.Success       = false;
                    result.ResultMessage = "Model is not valid";
                    result.errors        = ModelState.Values.SelectMany(e => e.Errors.Select(er => er.ErrorMessage));
                }
            }
            catch (Exception ex)
            {
                result.Success       = false;
                result.ResultMessage = "Failed to save Data";
                result.ExceptionInfo = new ExceptionInfo(ex);
            }
            return(JsonConvert.SerializeObject(result));
        }