public JsonResult AddUpdateCondition(long conditionID, PatientConditions_Custom condition) { try { if (condition.conditionName == null || condition.conditionName == "" || !Regex.IsMatch(condition.conditionName, "^[0-9a-zA-Z ]+$")) { ApiResultModel apiresult = new ApiResultModel(); apiresult.message = "Invalid condition name.Only letters and numbers are allowed."; return(Json(new { Success = true, ApiResultModel = apiresult })); } ConditionRepository objRepo = new ConditionRepository(); if (conditionID == 0) { ApiResultModel apiresult = new ApiResultModel(); apiresult = objRepo.AddCondition(condition); return(Json(new { Success = true, ApiResultModel = apiresult })); } else { ApiResultModel apiresult = objRepo.EditCondition(conditionID, condition); return(Json(new { Success = true, ApiResultModel = apiresult })); } } catch (Exception ex) { return(Json(new { Message = ex.Message })); } }
public void AddPlant(Plant plant, Models.Model.Condition condition, Soil soil, Fertilizer fertilizer) { int conditionId = conditionRepository.AddCondition(condition, soil.SoilId); fertilizerRepository.AddFertilizerCondition(fertilizer.FertilizerId, conditionId, fertilizer.Count); plantRepository.AddPlant(plant, 2); }