Beispiel #1
0
        public IHttpActionResult PutSchoolMaster(SchoolMaster schoolMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Entry(schoolMaster).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SchoolMasterExists(schoolMaster.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public int Update(SchoolModel model)
        {
            Mapper.CreateMap <SchoolModel, SchoolMaster>();
            SchoolMaster objUser = Dbcontext.SchoolMasters.SingleOrDefault(m => m.SchoolID == model.SchoolID);

            objUser = Mapper.Map(model, objUser);
            return(Dbcontext.SaveChanges());
        }
 public long Save(SchoolMaster master)
 {
     if (master.SchoolId == 0)
     {
         db.SchoolMasters.Add(master);
     }
     db.SaveChanges();
     return(master.SchoolId);
 }
Beispiel #4
0
        public async Task <IHttpActionResult> DeleteSchoolMaster(int id)
        {
            SchoolMaster schoolMaster = await db.Schools.FindAsync(id);

            if (schoolMaster == null)
            {
                return(NotFound());
            }

            db.Schools.Remove(schoolMaster);
            await db.SaveChangesAsync();

            return(Ok(schoolMaster));
        }
Beispiel #5
0
 public SchoolModel getByID(int id)
 {
     try
     {
         Mapper.CreateMap <SchoolMaster, SchoolModel>();
         SchoolMaster objCityMaster = Dbcontext.SchoolMasters.Where(m => m.SchoolID == id).SingleOrDefault();
         SchoolModel  objCityItem   = Mapper.Map <SchoolModel>(objCityMaster);
         return(objCityItem);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #6
0
        //public List<SchoolModel> getPComp()
        //{
        //    try
        //    {
        //        Mapper.CreateMap<SchoolMaster, SchoolModel>();
        //        List<SchoolMaster> objCityMaster = Dbcontext.SchoolMasters.Where(m => m.Status == true && m.PCompID == null).ToList();
        //        List<SchoolModel> objCityItem = Mapper.Map<List<SchoolModel>>(objCityMaster);
        //        return objCityItem;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        public int Insert(SchoolModel model)
        {
            try
            {
                Mapper.CreateMap <SchoolModel, SchoolMaster>();
                SchoolMaster objUser = Mapper.Map <SchoolMaster>(model);
                Dbcontext.SchoolMasters.Add(objUser);
                return(Dbcontext.SaveChanges());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #7
0
        public static SchoolMasterModel Mapping(SchoolMaster db)
        {
            SchoolMasterModel model = new SchoolMasterModel();

            model.SchoolId   = db.SchoolId;
            model.SchoolName = db.SchoolName;
            model.IsActive   = db.IsActive;
            model.IsDelete   = db.IsDelete;
            model.CreatedBy  = db.CreatedBy;
            model.CreatedOn  = db.CreatedOn;
            model.UpdatedBy  = db.UpdatedBy;
            model.UpdatedOn  = db.UpdatedOn;

            return(model);
        }
        public bool Delete(long id)
        {
            SchoolMaster master = GetSchoolMasterById(id);

            if (master != null)
            {
                db.SchoolMasters.Remove(master);
                db.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
 public bool DeleteByID(int id)
 {
     try
     {
         Mapper.CreateMap <SchoolMaster, SchoolModel>();
         SchoolMaster objCityMaster = Dbcontext.SchoolMasters.Where(m => m.SchoolID == id).SingleOrDefault();
         Dbcontext.SchoolMasters.Remove(objCityMaster);
         Dbcontext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Beispiel #10
0
        static void Main(string[] args)
        {
            SchoolMaster schoolmaster = new SchoolMaster();
            Teacher      T1           = new Teacher("陈老师", schoolmaster);
            Teacher      T2           = new Teacher("李老师", schoolmaster);
            Student      S1           = new Student("小赵", schoolmaster);

            schoolmaster.Criticized();

            Adaptee  adaptee  = new Adaptee();
            Adaptera adapters = new Adaptera();

            adapters.GetAdaptee(adaptee);
            adapters.VoltageChange();

            Console.ReadKey();
        }
        public async Task <IHttpActionResult> PostSchoolMaster(SchoolMasterViewModel schoolMasterViewModel)
        {
            //schoolMasterViewModel.SchoolImage = File.ReadAllBytes(@"D:\Rhino.PNG");
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var school = from state in db.States
                         join branch in db.Branches on state.BranchId equals branch.Id
                         join zone in db.Zones on branch.ZoneId equals zone.Id
                         join country in db.Countries on zone.CountryId equals country.Id
                         where state.Id == schoolMasterViewModel.StateId
                         select new SchoolMasterViewModel
            {
                CountryId                   = country.Id,
                ZoneId                      = zone.Id,
                BranchId                    = branch.Id,
                StateId                     = schoolMasterViewModel.StateId,
                SchoolType                  = schoolMasterViewModel.SchoolType,
                SchoolName                  = schoolMasterViewModel.SchoolName,
                HouseNumber                 = schoolMasterViewModel.HouseNumber,
                Street                      = schoolMasterViewModel.Street,
                Area                        = schoolMasterViewModel.Area,
                LGA                         = schoolMasterViewModel.LGA,
                LandMark                    = schoolMasterViewModel.LandMark,
                GeoCoordinate               = schoolMasterViewModel.GeoCoordinate,
                PrincipalName               = schoolMasterViewModel.PrincipalName,
                PhoneNumber                 = schoolMasterViewModel.PhoneNumber,
                SchoolPhoneNumber           = schoolMasterViewModel.SchoolPhoneNumber,
                TotalPopulation             = schoolMasterViewModel.TotalPopulation,
                TotalEducationlevel         = schoolMasterViewModel.TotalEducationlevel,
                NursaryToPrimary3Population = schoolMasterViewModel.NursaryToPrimary3Population,
                Approved                    = schoolMasterViewModel.Approved,
                Source                      = schoolMasterViewModel.Source,
                Status                      = schoolMasterViewModel.Status
            };
            var          schoolModel  = school.FirstOrDefault();
            SchoolMaster schoolMaster = new SchoolMaster();

            schoolMaster.Id                          = schoolMasterViewModel.Id;
            schoolMaster.CountryId                   = schoolMasterViewModel.CountryId;
            schoolMaster.ZoneId                      = schoolMasterViewModel.ZoneId;
            schoolMaster.BranchId                    = schoolMasterViewModel.BranchId;
            schoolMaster.StateId                     = schoolMasterViewModel.StateId;
            schoolMaster.SchoolType                  = schoolMasterViewModel.SchoolType;
            schoolMaster.SchoolName                  = schoolMasterViewModel.SchoolName;
            schoolMaster.HouseNumber                 = schoolMasterViewModel.HouseNumber;
            schoolMaster.Street                      = schoolMasterViewModel.Street;
            schoolMaster.Area                        = schoolMasterViewModel.Area;
            schoolMaster.LGA                         = schoolMasterViewModel.LGA;
            schoolMaster.LandMark                    = schoolMasterViewModel.LandMark;
            schoolMaster.GeoCoordinate               = schoolMasterViewModel.GeoCoordinate;
            schoolMaster.PrincipalName               = schoolMasterViewModel.PrincipalName;
            schoolMaster.PhoneNumber                 = schoolMasterViewModel.PhoneNumber;
            schoolMaster.SchoolPhoneNumber           = schoolMasterViewModel.SchoolPhoneNumber;
            schoolMaster.TotalPopulation             = schoolMasterViewModel.TotalPopulation;
            schoolMaster.TotalEducationlevel         = schoolMasterViewModel.TotalEducationlevel;
            schoolMaster.NursaryToPrimary3Population = schoolMasterViewModel.NursaryToPrimary3Population;
            schoolMaster.Approved                    = schoolMasterViewModel.Approved;
            schoolMaster.Source                      = schoolMasterViewModel.Source;
            schoolMaster.Status                      = schoolMasterViewModel.Status;
            schoolMaster.SchoolImage                 = schoolMasterViewModel.SchoolImage;
            schoolMaster.Created                     = DateTime.Now;
            schoolMaster.Updated                     = DateTime.Now;
            if (schoolMaster.Id > 0)
            {
                return(PutSchoolMaster(schoolMaster));
            }
            try
            {
                db.Schools.Add(schoolMaster);
                await db.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(CreatedAtRoute("DefaultApi", new { id = schoolMaster.Id }, schoolMaster));
        }