Exemplo n.º 1
0
        public void SendEmailInfoElement(dynamic contact, Customer customer, ElementExtended element, string idCulture)
        {
            XDocument xml = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
                                          new XElement("Root",
                                                       new XElement("Data",
                                                                    new XElement("SiteName", SpongeSolutions.ServicoDireto.Admin.Properties.Settings.Default.SiteName),
                                                                    new XElement("IDElement", element.IDElement),
                                                                    new XElement("Title", element.Name),
                                                                    new XElement("Description", element.Description),
                                                                    new XElement("Name", (string)contact.name),
                                                                    new XElement("Email", (string)contact.email),
                                                                    new XElement("Site", SpongeSolutions.ServicoDireto.Admin.Properties.Settings.Default.SitePath),
                                                                    new XElement("Message", (string)contact.message))));

            EmailHelper.Send(customer.Email,
                             SpongeSolutions.ServicoDireto.Internationalization.Label.Request_Element_Info,
                             HttpContext.Current.Server.MapPath(String.Format("/templates/{0}/CustomerInfoElement.xsl",
                                                                              idCulture)), xml);
        }
Exemplo n.º 2
0
        public IHttpActionResult InsertUpdateElement([FromBody] ElementExtended entity)
        {
            IList <ElementAttribute> selectedAttributes = null;
            IList <ElementCulture>   elementCulture     = new List <ElementCulture>();

            selectedAttributes = (from ea in entity.BasicAttributes
                                  where ea.Checked == true
                                  select new ElementAttribute
            {
                IDAttribute = ea.IDAttribute.Value,
                Value = ea.Value
            }).ToList();

            Element element = new Element();

            ObjectCopier.Copy(entity, element);

            //TODO: colocar validacao server-side e imagens
            elementCulture.Add(new ElementCulture()
            {
                Description = entity.Description,
                IDCulture   = entity.IDCulture,
                IDElement   = entity.IDElement.HasValue ? entity.IDElement.Value : 0,
                Name        = entity.Name
            });

            if (!element.IDElement.HasValue)
            {
                element.Status     = (short)Model.InfraStructure.Enums.StatusType.Active;
                element.IDCustomer = this.GetAuthCustomer().IDCustomer.Value;
                element.CreateDate = DateTime.Now;
                element.CreatedBy  = SiteContext.ActiveUserName;
                element.ModifyDate = DateTime.Now;
                element.ModifiedBy = SiteContext.ActiveUserName;
                ServiceContext.ElementService.Insert(element, elementCulture, selectedAttributes);

                return(Ok(new
                {
                    IDElement = element.IDElement,
                    IDCustomer = element.IDCustomer,
                    Message = Internationalization.Message.Element_Inserted_Successfully
                }));
            }
            else
            {
                if (CheckOwnership(element.IDCustomer))
                {
                    //entity.DefaultPicturePath = this.DefaultPicturePath(entity.IDCustomer, entity.IDElement.Value);
                    element.ModifyDate = DateTime.Now;
                    element.ModifiedBy = SiteContext.ActiveUserName;
                    ServiceContext.ElementService.Update(element, elementCulture, selectedAttributes);
                    return(Ok(new
                    {
                        IDElement = element.IDElement,
                        IDCustomer = element.IDCustomer,
                        Message = Internationalization.Message.Element_Updated_Successfully
                    }));
                }
                else
                {
                    return(BadRequest(Internationalization.Message.Element_Does_Not_Belongs_To_Customer));
                }
            }
        }
Exemplo n.º 3
0
 public ActionResult ListItem(ElementExtended item)
 {
     item.DefaultPicturePath = this.DefaultPicturePath(item.IDCustomer, item.IDElement.Value);
     //ViewBag.BasicAttributes = Context.AttributeService.List("BASIC", item.IDElement.Value);
     return(View(item));
 }