Esempio n. 1
0
 public string Add(Channel channel)
 {
     try
     {
         if (channel != null)
         {
             if (!IsDuplicate(string.Empty, channel.ChannelName))
             {
                 channel.ChannelID = Guid.NewGuid().ToString();
                 channel.UpdateBy = CommonConstant.GetFieldValueString(Session[CommonConstant.SessionUserID]);
                 channel.UpdateDate = DateTime.Now;
                 channel.CreateBy = CommonConstant.GetFieldValueString(Session[CommonConstant.SessionUserID]);
                 channel.CreateDate = DateTime.Now;
                 db.Channels.Add(channel);
                 db.SaveChanges();
                 return "Success";
             }
             else
             {
                 return "This channel name already in used.";
             }
         }
     }
     catch(Exception ex)
     {
         LogFile.writeLogFile(DateTime.Now, "ChannelController", ex.ToString());
     }
     return "Add channel failed.";
 }
Esempio n. 2
0
 public string Update(Channel channel)
 {
     try
     {
         if (channel != null)
         {
             if (!IsDuplicate(channel.ChannelID, channel.ChannelName))
             {
                 var chan = db.Channels.Find(channel.ChannelID);
                 chan.ChannelName = channel.ChannelName;
                 chan.iOSUrl = channel.iOSUrl;
                 chan.BrowserUrl = channel.BrowserUrl;
                 chan.AndroidUrl = channel.AndroidUrl;
                 chan.ChannelStatus = channel.ChannelStatus;
                 chan.UpdateDate = DateTime.Now;
                 chan.UpdateBy = CommonConstant.GetFieldValueString(Session[CommonConstant.SessionUserID]);
                 db.Entry(chan).State = EntityState.Modified;
                 db.SaveChanges();
                 return "Success";
             }
             else
             {
                 return "This channel name already in used.";
             }
         }
     }
     catch (Exception ex) { LogFile.writeLogFile(DateTime.Now, "ChannelController", ex.ToString()); }
     return "Update failed";
 }