예제 #1
0
        /// <summary>
        /// Add VentilationMonitor Record
        /// </summary>

        public IActionResult AddRecord(VentilationMonitorDto data)
        {
            try
            {
                var model = _mapper.Map <VentilationMonitorModel>(data);

                // Check If Unit Exist
                var value = _unRepo.unitExists(data.Unit);
                if (!value)
                {
                    // Insert Data in Unit table
                    var objUnit = _unRepo.CreateUnit(data.Unit);
                    model.UnitId = objUnit.UnitId;
                    var status = _vmRepo.CreateVentilationSystem(model);
                    if (status)
                    {
                        return(Json(new { success = true, message = "Record Added succesfully" }));
                    }
                    else
                    {
                        return(Json(new { success = false, message = "Something went wrong.Please try again later!" }));
                    }
                }
                else
                {
                    return(Json(new { success = false, message = "Record already exists!" }));
                }
            }
            catch (Exception ex)
            {
                // TODO:
                // Log the error in sql tabel
                //
                return(Json(new { success = false, message = "Something went wrong.Please try again later!" }));
            }
        }