Пример #1
0
        /// <summary>
        /// save new treatment
        /// </summary>
        public TreatmentRes Save(int doctorId, TreatmentReq req)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    var cat = new catrecetas
                    {
                        idmedico = doctorId,
                        nombre   = req.GroupName,
                        lineas   = string.Join("|", req.List)
                    };

                    Context.catrecetas.Add(cat);
                    Context.SaveChanges();
                    scope.Complete();
                    return(new TreatmentRes
                    {
                        Id = cat.idcatreceta
                    });
                }
            }
            catch (Exception ex)
            {
                Log.Write($"WebAPI.Services.Diagnostic - Save=> {ex.Message}");
            }
            return(new TreatmentRes());
        }
Пример #2
0
        /// <summary>
        /// remove treatments from the doctor's
        /// treatment catalog
        /// </summary>
        public bool Delete(int treatmentId)
        {
            var register = new catrecetas {
                idcatreceta = treatmentId
            };

            Context.catrecetas.Attach(register);
            Context.catrecetas.Remove(register);
            try
            {
                Context.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                Log.Write($"WebAPI.Services._Treatment - Delete => {ex.Message}");
            }
            return(false);
        }