Ejemplo n.º 1
0
        public void Update(CharityRecordUiModel model)
        {
            try
            {
                using (CharityEntities entities = new CharityEntities())
                {
                    CharityRecord charityRecord = new CharityRecord();
                    var           record        = entities.CharityRecords.Include(x => x.FileDetails).Where(x => x.Id == model.id).FirstOrDefault();

                    record.Title         = model.Title;
                    record.Description   = model.Description;
                    record.Charity       = model.Charity;
                    record.PlayItForward = model.PlayItFwd;
                    record.UserId        = model.UserId;
                    record.Currency      = model.Currency;

                    foreach (var item in model.FileDetails)
                    {
                        FileDetail detailsobj = new FileDetail();
                        detailsobj.FileInfo  = item.FileInfo;
                        detailsobj.FileName  = item.FileName;
                        detailsobj.CharityId = item.CharityId;
                        entities.FileDetails.Add(detailsobj);
                    }

                    entities.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public void Write(CharityRecordUiModel record)
        {
            try
            {
                using (CharityEntities entities = new CharityEntities())
                {
                    CharityRecord charityRecord = new CharityRecord();

                    charityRecord.Title         = record.Title;
                    charityRecord.Description   = record.Description;
                    charityRecord.Charity       = record.Charity;
                    charityRecord.PlayItForward = record.PlayItFwd;
                    charityRecord.UserId        = record.UserId;
                    charityRecord.Currency      = record.Currency;
                    charityRecord.Status        = 0;
                    entities.CharityRecords.Add(charityRecord);
                    foreach (var item in record.FileDetails)
                    {
                        FileDetail detailsobj = new FileDetail();
                        detailsobj.FileInfo  = item.FileInfo;
                        detailsobj.FileName  = item.FileName;
                        detailsobj.CharityId = charityRecord.Id;
                        entities.FileDetails.Add(detailsobj);
                    }


                    entities.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public CharityRecordUiModel LoadRecordtoEdit(int trid)
        {
            using (CharityEntities entities = new CharityEntities())
            {
                var result = entities.CharityRecords.Where(x => x.Id == trid).Include(x => x.FileDetails).
                             FirstOrDefault();
                List <FileDetailsUiModel> files = new List <FileDetailsUiModel>();
                foreach (var item in result.FileDetails)
                {
                    FileDetailsUiModel model = new FileDetailsUiModel();
                    model.FileInfo  = item.FileInfo;
                    model.FileName  = item.FileName;
                    model.CharityId = item.CharityId;
                    model.id        = item.Id;
                    files.Add(model);
                }

                var record = new CharityRecordUiModel()
                {
                    Charity     = result.Charity,
                    Currency    = (float)result.Currency,
                    Description = result.Description,
                    id          = result.Id,
                    PlayItFwd   = result.PlayItForward,
                    Title       = result.Title,
                    UserId      = result.UserId,
                    FileDetails = files
                };


                return(record);
            }
        }
 public List <CharityRecordUiModel> GetRecords()
 {
     using (CharityEntities entities = new CharityEntities())
     {
         List <CharityRecord> record = entities.CharityRecords.ToList();
         var model = new List <CharityRecordUiModel>();
         foreach (var item in record)
         {
             var result = new CharityRecordUiModel()
             {
                 Charity     = item.Charity,
                 Currency    = (float)item.Currency,
                 Description = item.Description,
                 id          = item.Id,
                 PlayItFwd   = item.PlayItForward,
                 Title       = item.Title,
                 UserId      = item.UserId,
                 IsAdmin     = true,
                 status      = GetStatus(item.Status)
             };
             model.Add(result);
         }
         return(model);
     }
 }
Ejemplo n.º 5
0
 public void ApproveCharity(int trid)
 {
     using (CharityEntities entities = new CharityEntities())
     {
         var result = entities.CharityRecords.Where(x => x.Id == trid).FirstOrDefault();
         result.Status = 1;
         entities.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 public void DeleteRecord(int trid)
 {
     try
     {
         using (CharityEntities entities = new CharityEntities())
         {
             var result = entities.CharityRecords.Where(x => x.Id == trid).Include(x => x.FileDetails).
                          FirstOrDefault();
             entities.FileDetails.RemoveRange(result.FileDetails);
             entities.CharityRecords.Remove(result);
             entities.SaveChanges();
         }
     }
     catch
     {
         throw;
     }
 }