Exemple #1
0
        public async Task <RulesRegulation> SaveRulesRegulation(RulesRegulation RulesRegulation)
        {
            if (RulesRegulation.Id == 0)
            {
                _context.RulesRegulation.Add(RulesRegulation);
            }
            else
            {
                RulesRegulation rr = _context.RulesRegulation.Find(RulesRegulation.Id);

                if (rr != null)
                {
                    //Update that PoliceStation
                    rr.RuleDetails = RulesRegulation.RuleDetails;
                    rr.BranchId    = RulesRegulation.BranchId;
                    _context.RulesRegulation.Update(rr);
                }
            }
            try
            {
                await _context.SaveChangesAsync();

                return(RulesRegulation);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public async Task <RulesRegulation> DeleteRulesRegulation(int id)
        {
            RulesRegulation rr = _context.RulesRegulation.Find(id);

            if (rr != null)
            {
                _context.RulesRegulation.Remove(rr);
            }
            try
            {
                await _context.SaveChangesAsync();

                return(rr);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }