private bool CheckValidity(IcuDataModel icu)
 {
     if (icu.Layout != null && icu.TotalNoOfBeds > 0)
     {
         return(true);
     }
     return(false);
 }
Beispiel #2
0
        public IActionResult Delete(string id)
        {
            IcuDataModel result = _icudatabase.RemoveIcu(id);

            if (result != null)
            {
                return(Ok(result));
            }
            return(BadRequest("Icu does not exist!"));
        }
Beispiel #3
0
        public IActionResult Get(string id)
        {
            IcuDataModel icu = _icudatabase.GetIcuDetailsById(id);

            if (icu != null)
            {
                return(Ok(icu));
            }
            return(BadRequest("Icu not found!"));
        }
 public IcuDataModel AddIcu(IcuDataModel icu)
 {
     //IcuDataModel _icu = _context.Icu.Find(icu.IcuId);
     if (icu != null && CheckValidity(icu))
     {
         _context.Icu.Add(icu);
         _context.SaveChanges();
         return(icu);
     }
     return(null);
 }
Beispiel #5
0
        public IActionResult GetBeds(string id)
        {
            IcuDataModel icu = _icudatabase.GetIcuDetailsById(id);

            if (icu != null)
            {
                int bedNo = icu.TotalNoOfBeds;
                return(Ok(bedNo));
            }
            return(BadRequest("Icu does not exist!"));
        }
Beispiel #6
0
        public IActionResult GetLayout(string id)
        {
            IcuDataModel icu = _icudatabase.GetIcuDetailsById(id);

            if (icu != null)
            {
                string layout = icu.Layout;
                return(Ok(layout));
            }
            return(BadRequest("Icu does not exist!"));
        }
        public bool UpdateLayout(string icuId, string layout)
        {
            IcuDataModel icu = _context.Icu.Find(icuId);

            if (icu != null)
            {
                icu.Layout = layout;
                _context.SaveChanges();
                return(true);
            }
            return(false);
        }
        public IcuDataModel RemoveIcu(string icuId)
        {
            IcuDataModel icu = _context.Icu.Find(icuId);

            if (icu != null)
            {
                _context.Icu.Remove(icu);
                _context.SaveChanges();
                return(icu);
            }
            return(null);
        }
Beispiel #9
0
        public ConfigurationViewModel()
        {
            Layouts = new ObservableCollection <string>()
            {
                "L Shape",
                "Parallel"
            };

            _icuDataModel = new IcuDataModel("", 1, Layouts[0]);

            AddIcuCommand = new Command.DelegateCommandClass(AddIcuWrapper, CanExecuteWrapper);
        }
Beispiel #10
0
 public IActionResult Put(string id, [FromBody] IcuDataModel icuDetailsChanges)
 {
     if (icuDetailsChanges.IcuId == id)
     {
         var result = _icudatabase.UpdateIcu(icuDetailsChanges);
         if (result != null)
         {
             return(Ok(result));
         }
     }
     return(BadRequest("Icu does not exist"));
 }
Beispiel #11
0
        internal static async Task <string> PostIcuData(IcuDataModel requestObj)
        {
            try
            {
                HttpResponseMessage response = await Client.PostAsJsonAsync("api/IcuData/", requestObj).ConfigureAwait(false);

                return(ConvertHttpResponseToStringResponse(ref response));
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Beispiel #12
0
        public IActionResult Post([FromBody] IcuDataModel icu)
        {
            if (_icudatabase.GetIcuDetailsById(icu.IcuId) != null)
            {
                return(BadRequest("Icu already exists"));
            }

            var result = _icudatabase.AddIcu(icu);

            if (result != null)
            {
                return(Ok("Icu added successfully"));
            }

            return(BadRequest("One or more Icu details are not valid!"));
        }
        public IcuDataModel UpdateIcu(IcuDataModel icuDetailsChanges)
        {
            string id = icuDetailsChanges.IcuId;

            if (_context.Icu.Find(id) != null)
            {
                IcuDataModel icu = _context.Icu.Find(id);
                if (icu != null)
                {
                    icu.Layout        = icuDetailsChanges.Layout;
                    icu.TotalNoOfBeds = icuDetailsChanges.TotalNoOfBeds;
                    _context.SaveChanges();
                    return(icu);
                }
                return(null);
            }
            return(null);
        }
        public IcuDataModel GetIcuDetailsById(string icuId)
        {
            IcuDataModel icu = _context.Icu.Find(icuId);

            return(icu);
        }